[llvm] cb09b5f - [MC] Disable MCAssembler based constant folding for compact unwind and emitJumpTableEntry
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 15:06:17 PDT 2024
Author: Fangrui Song
Date: 2024-06-04T15:06:12-07:00
New Revision: cb09b5f3d53e5b7b4452bb3db78dca79fc9b3f17
URL: https://github.com/llvm/llvm-project/commit/cb09b5f3d53e5b7b4452bb3db78dca79fc9b3f17
DIFF: https://github.com/llvm/llvm-project/commit/cb09b5f3d53e5b7b4452bb3db78dca79fc9b3f17.diff
LOG: [MC] Disable MCAssembler based constant folding for compact unwind and emitJumpTableEntry
Similar to commit 245491a9f384e4c53421196533c2a2b693efaf8d for DwarfDebug.
This completely disables the expensive MCFragment walk code in
`AttemptToFoldSymbolOffsetDifference` when compiling sqlite3.i for
macOS.
In the future, we should try enabling the MCFragment walk only for
constructs like `.if . -_start == 1` and `.subsection a-b` and
remove these `setUseAssemblerInfoForParsing`.
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCDwarf.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index c5755b9bdc8d0..e8bab26907b7e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2801,8 +2801,12 @@ void AsmPrinter::emitJumpTableInfo() {
MCSymbol* JTISymbol = GetJTISymbol(JTI);
OutStreamer->emitLabel(JTISymbol);
+ // Defer MCAssembler based constant folding due to a performance issue. The
+ // label
diff erences will be evaluated at write time.
+ OutStreamer->setUseAssemblerInfoForParsing(false);
for (const MachineBasicBlock *MBB : JTBBs)
emitJumpTableEntry(MJTI, MBB, JTI);
+ OutStreamer->setUseAssemblerInfoForParsing(true);
}
if (!JTInDiffSection)
OutStreamer->emitDataRegion(MCDR_DataRegionEnd);
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index aba4071e6b910..f7bc3a6bbe538 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1864,6 +1864,12 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
FrameEmitterImpl Emitter(IsEH, Streamer);
ArrayRef<MCDwarfFrameInfo> FrameArray = Streamer.getDwarfFrameInfos();
+ // Disable AttemptToFoldSymbolOffsetDifference folding of EmitCompactUnwind
+ // and fdeStart-cieStart for EmitFDE due to the the performance issue. The
+ // label
diff erences will be evaluate at write time.
+ assert(Streamer.getUseAssemblerInfoForParsing());
+ Streamer.setUseAssemblerInfoForParsing(false);
+
// Emit the compact unwind info if available.
bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();
if (IsEH && MOFI->getCompactUnwindSection()) {
@@ -1910,11 +1916,6 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
[](const MCDwarfFrameInfo &X, const MCDwarfFrameInfo &Y) {
return CIEKey(X) < CIEKey(Y);
});
- // Disable AttemptToFoldSymbolOffsetDifference folding of fdeStart-cieStart
- // for EmitFDE due to the the performance issue. The label
diff erences will be
- // evaluate at write time.
- assert(Streamer.getUseAssemblerInfoForParsing());
- Streamer.setUseAssemblerInfoForParsing(false);
for (auto I = FrameArrayX.begin(), E = FrameArrayX.end(); I != E;) {
const MCDwarfFrameInfo &Frame = *I;
++I;
More information about the llvm-commits
mailing list