Skip to content

Commit cb09b5f

Browse files
committed
[MC] Disable MCAssembler based constant folding for compact unwind and emitJumpTableEntry
Similar to commit 245491a 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`.
1 parent e949b54 commit cb09b5f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,8 +2801,12 @@ void AsmPrinter::emitJumpTableInfo() {
28012801
MCSymbol* JTISymbol = GetJTISymbol(JTI);
28022802
OutStreamer->emitLabel(JTISymbol);
28032803

2804+
// Defer MCAssembler based constant folding due to a performance issue. The
2805+
// label differences will be evaluated at write time.
2806+
OutStreamer->setUseAssemblerInfoForParsing(false);
28042807
for (const MachineBasicBlock *MBB : JTBBs)
28052808
emitJumpTableEntry(MJTI, MBB, JTI);
2809+
OutStreamer->setUseAssemblerInfoForParsing(true);
28062810
}
28072811
if (!JTInDiffSection)
28082812
OutStreamer->emitDataRegion(MCDR_DataRegionEnd);

llvm/lib/MC/MCDwarf.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,12 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
18641864
FrameEmitterImpl Emitter(IsEH, Streamer);
18651865
ArrayRef<MCDwarfFrameInfo> FrameArray = Streamer.getDwarfFrameInfos();
18661866

1867+
// Disable AttemptToFoldSymbolOffsetDifference folding of EmitCompactUnwind
1868+
// and fdeStart-cieStart for EmitFDE due to the the performance issue. The
1869+
// label differences will be evaluate at write time.
1870+
assert(Streamer.getUseAssemblerInfoForParsing());
1871+
Streamer.setUseAssemblerInfoForParsing(false);
1872+
18671873
// Emit the compact unwind info if available.
18681874
bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();
18691875
if (IsEH && MOFI->getCompactUnwindSection()) {
@@ -1910,11 +1916,6 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
19101916
[](const MCDwarfFrameInfo &X, const MCDwarfFrameInfo &Y) {
19111917
return CIEKey(X) < CIEKey(Y);
19121918
});
1913-
// Disable AttemptToFoldSymbolOffsetDifference folding of fdeStart-cieStart
1914-
// for EmitFDE due to the the performance issue. The label differences will be
1915-
// evaluate at write time.
1916-
assert(Streamer.getUseAssemblerInfoForParsing());
1917-
Streamer.setUseAssemblerInfoForParsing(false);
19181919
for (auto I = FrameArrayX.begin(), E = FrameArrayX.end(); I != E;) {
19191920
const MCDwarfFrameInfo &Frame = *I;
19201921
++I;

0 commit comments

Comments
 (0)