[llvm] 626eef5 - [MC] Optimize getCurrentSectionOnly using CurFrag and make it non-nullable
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 22:51:35 PDT 2024
Author: Fangrui Song
Date: 2024-06-27T22:51:30-07:00
New Revision: 626eef5ecf92e98cbfccfa6134e0a760e7592813
URL: https://github.com/llvm/llvm-project/commit/626eef5ecf92e98cbfccfa6134e0a760e7592813
DIFF: https://github.com/llvm/llvm-project/commit/626eef5ecf92e98cbfccfa6134e0a760e7592813.diff
LOG: [MC] Optimize getCurrentSectionOnly using CurFrag and make it non-nullable
Follow-up to e48c4011ca80385573f1b92793c75dc98abb228f ("[MC] Cache current fragment in MCStreamer").
Prerequisite: a few commits that removed nullable getCurrentSectionOnly calls.
Added:
Modified:
llvm/include/llvm/MC/MCStreamer.h
llvm/lib/MC/MCELFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index 5c091dbdafe96..a5f53301e9de8 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -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 {
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 6d30f2efcc7de..e6e6b7d19dff4 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -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()));
}
More information about the llvm-commits
mailing list