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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne 2016-04-27 23:48:11 +00:00
parent 05e0103959
commit 628f22d543
2 changed files with 14 additions and 0 deletions

View File

@ -381,6 +381,10 @@ void LTOCodeGenerator::applyScopeRestrictions() {
// 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.

10
test/LTO/X86/unnamed.ll Normal file
View File

@ -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"
@0 = private global i32 42
@foo = constant i32* @0