[llvm] r254313 - Fix another llvm.ctors merging bug.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 10:54:25 PST 2015


Author: rafael
Date: Mon Nov 30 12:54:24 2015
New Revision: 254313

URL: http://llvm.org/viewvc/llvm-project?rev=254313&view=rev
Log:
Fix another llvm.ctors merging bug.

We were not looking past casts to see if an element should be included
or not.

Added:
    llvm/trunk/test/Linker/Inputs/ctors3.ll
    llvm/trunk/test/Linker/ctors3.ll
Modified:
    llvm/trunk/lib/Linker/LinkModules.cpp

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=254313&r1=254312&r2=254313&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Nov 30 12:54:24 2015
@@ -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(
 
   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;
     }

Added: llvm/trunk/test/Linker/Inputs/ctors3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/ctors3.ll?rev=254313&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/ctors3.ll (added)
+++ llvm/trunk/test/Linker/Inputs/ctors3.ll Mon Nov 30 12:54:24 2015
@@ -0,0 +1,7 @@
+$foo = comdat any
+%t = type { i8 }
+ at foo = global %t zeroinitializer, comdat
+ at 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
+}

Added: llvm/trunk/test/Linker/ctors3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/ctors3.ll?rev=254313&view=auto
==============================================================================
--- llvm/trunk/test/Linker/ctors3.ll (added)
+++ llvm/trunk/test/Linker/ctors3.ll Mon Nov 30 12:54:24 2015
@@ -0,0 +1,8 @@
+; RUN: llvm-link -S %s %p/Inputs/ctors3.ll -o - | FileCheck %s
+
+$foo = comdat any
+%t = type { i8 }
+ at foo = global %t zeroinitializer, comdat
+
+; CHECK: @foo = global %t zeroinitializer, comdat
+; CHECK: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer




More information about the llvm-commits mailing list