[PATCH] D32393: [ThinLTO/Summary] Rename anonymous globals as last action in the per-TU -O0 pipeline

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 22 21:37:32 PDT 2017


davide created this revision.
Herald added subscribers: inglorion, Prazek, mehdi_amini.

The problem is that there could be passes registered using `addExtensionsToPM()` introducing unnamed globals.
Asan is an example, but there may be others. Building cppcheck with `-thinlto` and `-fsanitize=address` triggers an assertion while we're reading bitcode (in lib/LTO), as the BitcodeReader while reading the summary assumes there are no unnamed globals because the namer has run).
Unfortunately I wasn't able to find an easy way to test this. I added a comment in the hope nobody moves this again, but, if folks have a way to test, I'm all ears.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32004


https://reviews.llvm.org/D32393

Files:
  lib/Transforms/IPO/PassManagerBuilder.cpp


Index: lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- lib/Transforms/IPO/PassManagerBuilder.cpp
+++ lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -414,11 +414,14 @@
     else if (!GlobalExtensions->empty() || !Extensions.empty())
       MPM.add(createBarrierNoopPass());
 
+    addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
+
+    // Rename anon globals to be able to export them in the summary.
+    // This has to be done after we add the extensions to the pass manager
+    // as there could be passes (e.g. Adddress sanitizer) which introduce
+    // new unnamed globals.
     if (PrepareForThinLTO)
-      // Rename anon globals to be able to export them in the summary.
       MPM.add(createNameAnonGlobalPass());
-
-    addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
     return;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32393.96293.patch
Type: text/x-patch
Size: 861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170423/f0139ffb/attachment.bin>


More information about the llvm-commits mailing list