Skip to content

Commit

Permalink
LTO: Don't bother trying to mangle unnamed globals, as they can't be …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
pcc committed Apr 27, 2016
1 parent 05e0103 commit 628f22d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/LTO/LTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions test/LTO/X86/unnamed.ll
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 628f22d

Please sign in to comment.