summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-11-30 18:54:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-11-30 18:54:24 +0000
commitc98b20b0d6edbb9659907eab879e7ff07391c9e3 (patch)
tree56b46669054f28b3caf4fe3fd549179d1c1a9114
parent96029f7880778a1a45932b71513c62124c877cd9 (diff)
downloadbcm5719-llvm-c98b20b0d6edbb9659907eab879e7ff07391c9e3.tar.gz
bcm5719-llvm-c98b20b0d6edbb9659907eab879e7ff07391c9e3.zip
Fix another llvm.ctors merging bug.
We were not looking past casts to see if an element should be included or not. llvm-svn: 254313
-rw-r--r--llvm/lib/Linker/LinkModules.cpp5
-rw-r--r--llvm/test/Linker/Inputs/ctors3.ll7
-rw-r--r--llvm/test/Linker/ctors3.ll8
3 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 6b60379803e..cdf1decc813 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -410,7 +410,7 @@ class ModuleLinker {
std::vector<AppendingVarInfo> AppendingVars;
// Set of items not to link in from source.
- SmallPtrSet<const Value *, 16> DoNotLinkFromSource;
+ SmallPtrSet<const GlobalValue *, 16> DoNotLinkFromSource;
DiagnosticHandlerFunction DiagnosticHandler;
@@ -1512,7 +1512,8 @@ void ModuleLinker::linkAppendingVarInit(AppendingVarInfo &AVI) {
for (auto *V : SrcElements) {
if (IsNewStructor) {
- Constant *Key = V->getAggregateElement(2);
+ auto *Key =
+ dyn_cast<GlobalValue>(V->getAggregateElement(2)->stripPointerCasts());
if (DoNotLinkFromSource.count(Key))
continue;
}
diff --git a/llvm/test/Linker/Inputs/ctors3.ll b/llvm/test/Linker/Inputs/ctors3.ll
new file mode 100644
index 00000000000..449ccbd90fa
--- /dev/null
+++ b/llvm/test/Linker/Inputs/ctors3.ll
@@ -0,0 +1,7 @@
+$foo = comdat any
+%t = type { i8 }
+@foo = global %t zeroinitializer, comdat
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* getelementptr (%t, %t* @foo, i32 0, i32 0) }]
+define internal void @bar() comdat($foo) {
+ ret void
+}
diff --git a/llvm/test/Linker/ctors3.ll b/llvm/test/Linker/ctors3.ll
new file mode 100644
index 00000000000..e62b92dca0b
--- /dev/null
+++ b/llvm/test/Linker/ctors3.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-link -S %s %p/Inputs/ctors3.ll -o - | FileCheck %s
+
+$foo = comdat any
+%t = type { i8 }
+@foo = global %t zeroinitializer, comdat
+
+; CHECK: @foo = global %t zeroinitializer, comdat
+; CHECK: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer
OpenPOWER on IntegriCloud