llvm.org GIT mirror llvm / 2e4508a
LTO: Don't internalize available_externally globals. This breaks C and C++ semantics because it can cause the address of the global inside the module to differ from the address outside of the module. Differential Revision: https://reviews.llvm.org/D55237 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348321 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 9 months ago
2 changed file(s) with 20 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
364364 // Ignore local and appending linkage values since the linker
365365 // doesn't resolve them.
366366 !GlobalValue::isLocalLinkage(S->linkage()) &&
367 !GlobalValue::isAppendingLinkage(S->linkage()))
367 S->linkage() != GlobalValue::AppendingLinkage &&
368 // We can't internalize available_externally globals because this
369 // can break function pointer equality.
370 S->linkage() != GlobalValue::AvailableExternallyLinkage)
368371 S->setLinkage(GlobalValue::InternalLinkage);
369372 }
370373 }
0 ; RUN: opt -module-summary -o %t.bc %s
1 ; RUN: llvm-lto2 run %t.bc -r %t.bc,foo,px -r %t.bc,bar, -o %t2
2 ; RUN: llvm-nm %t2.1 | FileCheck %s
3
4 ; CHECK: U bar
5
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
8
9 define void ()* @foo() {
10 ret void ()* @bar
11 }
12
13 define available_externally void @bar() {
14 ret void
15 }