[llvm] 85daa95 - [MC] Ensure UseAssemblerInfoForParsing is true upon return

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 16:39:23 PDT 2024


Author: Fangrui Song
Date: 2024-06-04T16:39:18-07:00
New Revision: 85daa95b18b3e9778d90f1fc72d2c1b4e8282b64

URL: https://github.com/llvm/llvm-project/commit/85daa95b18b3e9778d90f1fc72d2c1b4e8282b64
DIFF: https://github.com/llvm/llvm-project/commit/85daa95b18b3e9778d90f1fc72d2c1b4e8282b64.diff

LOG: [MC] Ensure UseAssemblerInfoForParsing is true upon return

Fixes: 5ee580bbfb11d781c220c19416c1a97b657e039a

5ee580bbfb11d781c220c19416c1a97b657e039a does not ensure that
UseAssemblerInfoForParsing is re-enabled. This is benign but not good.

Added: 
    

Modified: 
    llvm/lib/MC/MCDwarf.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index f7bc3a6bbe538..5032592b3861a 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -1869,6 +1870,8 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
   // label 
diff erences will be evaluate at write time.
   assert(Streamer.getUseAssemblerInfoForParsing());
   Streamer.setUseAssemblerInfoForParsing(false);
+  auto Enable = llvm::make_scope_exit(
+      [&]() { Streamer.setUseAssemblerInfoForParsing(true); });
 
   // Emit the compact unwind info if available.
   bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();
@@ -1936,7 +1939,6 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
 
     Emitter.EmitFDE(*CIEStart, Frame, I == E, *SectionStart);
   }
-  Streamer.setUseAssemblerInfoForParsing(true);
 }
 
 void MCDwarfFrameEmitter::encodeAdvanceLoc(MCContext &Context,


        


More information about the llvm-commits mailing list