Skip to content

Commit 626eef5

Browse files
committed
[MC] Optimize getCurrentSectionOnly using CurFrag and make it non-nullable
Follow-up to e48c401 ("[MC] Cache current fragment in MCStreamer"). Prerequisite: a few commits that removed nullable getCurrentSectionOnly calls.
1 parent db48f1a commit 626eef5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ class MCStreamer {
399399
return SectionStack.back().first;
400400
return MCSectionSubPair();
401401
}
402-
MCSection *getCurrentSectionOnly() const { return getCurrentSection().first; }
402+
MCSection *getCurrentSectionOnly() const {
403+
return CurFrag->getParent();
404+
}
403405

404406
/// Return the previous section that the streamer is emitting code to.
405407
MCSectionSubPair getPreviousSection() const {

llvm/lib/MC/MCELFStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void MCELFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
102102
// needs to be aligned to at least the bundle size.
103103
static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
104104
MCSection *Section) {
105-
if (Section && Assembler.isBundlingEnabled() && Section->hasInstructions())
105+
if (Assembler.isBundlingEnabled() && Section->hasInstructions())
106106
Section->ensureMinAlignment(Align(Assembler.getBundleAlignSize()));
107107
}
108108

0 commit comments

Comments
 (0)