Skip to content

Commit

Permalink
[MC] Optimize getCurrentSectionOnly using CurFrag and make it non-nul…
Browse files Browse the repository at this point in the history
…lable

Follow-up to e48c401 ("[MC] Cache current fragment in MCStreamer").

Prerequisite: a few commits that removed nullable getCurrentSectionOnly calls.
  • Loading branch information
MaskRay committed Jun 28, 2024
1 parent db48f1a commit 626eef5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion llvm/include/llvm/MC/MCStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ class MCStreamer {
return SectionStack.back().first;
return MCSectionSubPair();
}
MCSection *getCurrentSectionOnly() const { return getCurrentSection().first; }
MCSection *getCurrentSectionOnly() const {
return CurFrag->getParent();
}

/// Return the previous section that the streamer is emitting code to.
MCSectionSubPair getPreviousSection() const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/MC/MCELFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void MCELFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
// needs to be aligned to at least the bundle size.
static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
MCSection *Section) {
if (Section && Assembler.isBundlingEnabled() && Section->hasInstructions())
if (Assembler.isBundlingEnabled() && Section->hasInstructions())
Section->ensureMinAlignment(Align(Assembler.getBundleAlignSize()));
}

Expand Down

0 comments on commit 626eef5

Please sign in to comment.