[llvm] r267820 - 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 16:48:12 PDT 2016


Author: pcc
Date: Wed Apr 27 18:48:11 2016
New Revision: 267820

URL: http://llvm.org/viewvc/llvm-project?rev=267820&view=rev
Log:
LTO: Don't bother trying to mangle unnamed globals, as they can't be preserved with MustPreserveSymbols.

Summary: Should fix sanitizer-windows bot.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

Differential Revision: http://reviews.llvm.org/D19635

Added:
    llvm/trunk/test/LTO/X86/unnamed.ll
Modified:
    llvm/trunk/lib/LTO/LTOCodeGenerator.cpp

Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=267820&r1=267819&r2=267820&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Wed Apr 27 18:48:11 2016
@@ -381,6 +381,10 @@ void LTOCodeGenerator::applyScopeRestric
   // 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.

Added: llvm/trunk/test/LTO/X86/unnamed.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/X86/unnamed.ll?rev=267820&view=auto
==============================================================================
--- llvm/trunk/test/LTO/X86/unnamed.ll (added)
+++ llvm/trunk/test/LTO/X86/unnamed.ll Wed Apr 27 18:48:11 2016
@@ -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




More information about the llvm-commits mailing list