[llvm] r254543 - Also copy private linkage globals when needed.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 2 12:57:33 PST 2015


Author: rafael
Date: Wed Dec  2 14:57:33 2015
New Revision: 254543

URL: http://llvm.org/viewvc/llvm-project?rev=254543&view=rev
Log:
Also copy private linkage globals when needed.

This was an omission when handling COFF style comdats with local keys.
Should fix the sanitizer-windows bot.

Added:
    llvm/trunk/test/Linker/Inputs/comdat15.ll
    llvm/trunk/test/Linker/comdat15.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=254543&r1=254542&r2=254543&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Dec  2 14:57:33 2015
@@ -1426,7 +1426,7 @@ bool ModuleLinker::linkGlobalValueProto(
     std::tie(SK, LinkFromSrc) = ComdatsChosen[SC];
     C = DstM.getOrInsertComdat(SC->getName());
     C->setSelectionKind(SK);
-    if (SGV->hasInternalLinkage())
+    if (SGV->hasLocalLinkage())
       LinkFromSrc = true;
   } else if (DGV) {
     if (shouldLinkFromSource(LinkFromSrc, *DGV, *SGV))

Added: llvm/trunk/test/Linker/Inputs/comdat15.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/comdat15.ll?rev=254543&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/comdat15.ll (added)
+++ llvm/trunk/test/Linker/Inputs/comdat15.ll Wed Dec  2 14:57:33 2015
@@ -0,0 +1,6 @@
+$a1 = comdat any
+ at baz = private global i32 42, comdat($a1)
+ at a1 = internal alias i32, i32* @baz
+define i32* @abc() {
+  ret i32* @a1
+}

Added: llvm/trunk/test/Linker/comdat15.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/comdat15.ll?rev=254543&view=auto
==============================================================================
--- llvm/trunk/test/Linker/comdat15.ll (added)
+++ llvm/trunk/test/Linker/comdat15.ll Wed Dec  2 14:57:33 2015
@@ -0,0 +1,9 @@
+; RUN: llvm-link -S %s %p/Inputs/comdat15.ll -o - | FileCheck %s
+
+$a1 = comdat any
+ at bar = global i32 0, comdat($a1)
+
+; CHECK: @bar = global i32 0, comdat($a1)
+; CHECK: @baz = private global i32 42, comdat($a1)
+; CHECK: @a1 = internal alias i32, i32* @baz
+




More information about the llvm-commits mailing list