[llvm] 245491a - [MC] Disable MCAssembler based constant folding for DwarfDebug
    Fangrui Song via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon May 20 11:32:01 PDT 2024
    
    
  
Author: Fangrui Song
Date: 2024-05-20T11:31:56-07:00
New Revision: 245491a9f384e4c53421196533c2a2b693efaf8d
URL: https://github.com/llvm/llvm-project/commit/245491a9f384e4c53421196533c2a2b693efaf8d
DIFF: https://github.com/llvm/llvm-project/commit/245491a9f384e4c53421196533c2a2b693efaf8d.diff
LOG: [MC] Disable MCAssembler based constant folding for DwarfDebug
Related to the poor performance of MCAssembler based constant folding
(see `bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const` and
`AttemptToFoldSymbolOffsetDifference`),
commit 9500a5d02e23f9b43294e5f662ac099f8989c0e4 (#91082) caused -O0 -g
compile time regression.
9500a5d02e23f9b43294e5f662ac099f8989c0e4 special cased .eh_frame FDE
emitting. This patch adds a special case to .debug_* emitting as well to
mitigate the rest regression.
The MCAssembler based constant folding strategy should be improved to
remove the two special cases.
Added: 
    
Modified: 
    llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Removed: 
    
################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index d50cdc4323ecf..c5755b9bdc8d0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2463,11 +2463,15 @@ bool AsmPrinter::doFinalization(Module &M) {
     emitGlobalIFunc(M, IFunc);
 
   // Finalize debug and EH information.
+  // 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 HandlerInfo &HI : Handlers) {
     NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
                        HI.TimerGroupDescription, TimePassesIsEnabled);
     HI.Handler->endModule();
   }
+  OutStreamer->setUseAssemblerInfoForParsing(true);
 
   // This deletes all the ephemeral handlers that AsmPrinter added, while
   // keeping all the user-added handlers alive until the AsmPrinter is
        
    
    
More information about the llvm-commits
mailing list