[PATCH] D19635: LTO: Don't bother trying to mangle unnamed globals, as they can't be preserved with MustPreserveSymbols.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 15:23:31 PDT 2016


pcc created this revision.
pcc added a reviewer: joker.eph.
pcc added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.

Should fix sanitizer-windows bot.

http://reviews.llvm.org/D19635

Files:
  lib/LTO/LTOCodeGenerator.cpp
  test/LTO/X86/unnamed.ll

Index: test/LTO/X86/unnamed.ll
===================================================================
--- /dev/null
+++ test/LTO/X86/unnamed.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as -o %t.bc %s
+; RUN: llvm-lto -save-merged-module -o %t2 %t.bc
+; RUN: llvm-dis -o - %t2.merged.bc | FileCheck %s
+
+; CHECK-NOT: global i32
+
+target triple = "x86_64-unknown-linux-gnu"
+
+ at 0 = private global i32 42
+ at foo = constant i32* @0
Index: lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- lib/LTO/LTOCodeGenerator.cpp
+++ lib/LTO/LTOCodeGenerator.cpp
@@ -381,6 +381,10 @@
   // candidate GlobalValue if it can be internalized or not.
   SmallString<64> MangledName;
   auto mustPreserveGV = [&](const GlobalValue &GV) -> bool {
+    // Unnamed globals can't be mangled, but they can't be preserved either.
+    if (!GV.hasName())
+      return false;
+
     // Need to mangle the GV as the "MustPreserveSymbols" StringSet is filled
     // with the linker supplied name, which on Darwin includes a leading
     // underscore.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19635.55341.patch
Type: text/x-patch
Size: 1060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160427/d2d2b4be/attachment.bin>


More information about the llvm-commits mailing list