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;
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;
}
--- /dev/null
+$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
+}
--- /dev/null
+; 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