[llvm] r348321 - LTO: Don't internalize available_externally globals.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 16:09:37 PST 2018
Author: pcc
Date: Tue Dec 4 16:09:36 2018
New Revision: 348321
URL: http://llvm.org/viewvc/llvm-project?rev=348321&view=rev
Log:
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
Added:
llvm/trunk/test/LTO/Resolution/X86/available-externally.ll
Modified:
llvm/trunk/lib/LTO/LTO.cpp
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=348321&r1=348320&r2=348321&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Tue Dec 4 16:09:36 2018
@@ -365,7 +365,10 @@ static void thinLTOInternalizeAndPromote
// Ignore local and appending linkage values since the linker
// doesn't resolve them.
!GlobalValue::isLocalLinkage(S->linkage()) &&
- !GlobalValue::isAppendingLinkage(S->linkage()))
+ S->linkage() != GlobalValue::AppendingLinkage &&
+ // We can't internalize available_externally globals because this
+ // can break function pointer equality.
+ S->linkage() != GlobalValue::AvailableExternallyLinkage)
S->setLinkage(GlobalValue::InternalLinkage);
}
}
Added: llvm/trunk/test/LTO/Resolution/X86/available-externally.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/available-externally.ll?rev=348321&view=auto
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/available-externally.ll (added)
+++ llvm/trunk/test/LTO/Resolution/X86/available-externally.ll Tue Dec 4 16:09:36 2018
@@ -0,0 +1,16 @@
+; RUN: opt -module-summary -o %t.bc %s
+; RUN: llvm-lto2 run %t.bc -r %t.bc,foo,px -r %t.bc,bar, -o %t2
+; RUN: llvm-nm %t2.1 | FileCheck %s
+
+; CHECK: U bar
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void ()* @foo() {
+ ret void ()* @bar
+}
+
+define available_externally void @bar() {
+ ret void
+}
More information about the llvm-commits
mailing list