From: Rafael Espindola Date: Mon, 30 Nov 2015 18:54:24 +0000 (+0000) Subject: Fix another llvm.ctors merging bug. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=e87f0932d94a1bb29c7d4792adf8742ca165c4ef Fix another llvm.ctors merging bug. We were not looking past casts to see if an element should be included or not. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254313 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 6b60379803e..cdf1decc813 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -410,7 +410,7 @@ class ModuleLinker { std::vector AppendingVars; // Set of items not to link in from source. - SmallPtrSet DoNotLinkFromSource; + SmallPtrSet 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(V->getAggregateElement(2)->stripPointerCasts()); if (DoNotLinkFromSource.count(Key)) continue; } diff --git a/test/Linker/Inputs/ctors3.ll b/test/Linker/Inputs/ctors3.ll new file mode 100644 index 00000000000..449ccbd90fa --- /dev/null +++ b/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/test/Linker/ctors3.ll b/test/Linker/ctors3.ll new file mode 100644 index 00000000000..e62b92dca0b --- /dev/null +++ b/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