[llvm] r274722 - ThinLTO: Remove check for multiple modules before applying weak resolutions.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 18:51:11 PDT 2016


Author: pcc
Date: Wed Jul  6 20:51:11 2016
New Revision: 274722

URL: http://llvm.org/viewvc/llvm-project?rev=274722&view=rev
Log:
ThinLTO: Remove check for multiple modules before applying weak resolutions.

This check is not only unnecessary, it can produce the wrong result. If we
are linking a single module and it has an exported linkonce symbol, we need
to promote to weak in order to avoid PR19901-style problems.

Differential Revision: http://reviews.llvm.org/D21917

Added:
    llvm/trunk/test/ThinLTO/X86/weak_resolution_single.ll
Modified:
    llvm/trunk/lib/LTO/LTO.cpp

Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=274722&r1=274721&r2=274722&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Wed Jul  6 20:51:11 2016
@@ -92,10 +92,6 @@ void thinLTOResolveWeakForLinkerInIndex(
     function_ref<bool(StringRef, GlobalValue::GUID)> isExported,
     function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
         recordNewLinkage) {
-  if (Index.modulePaths().size() == 1)
-    // Nothing to do if we don't have multiple modules
-    return;
-
   // We won't optimize the globals that are referenced by an alias for now
   // Ideally we should turn the alias into a global and duplicate the definition
   // when needed.

Added: llvm/trunk/test/ThinLTO/X86/weak_resolution_single.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/weak_resolution_single.ll?rev=274722&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/weak_resolution_single.ll (added)
+++ llvm/trunk/test/ThinLTO/X86/weak_resolution_single.ll Wed Jul  6 20:51:11 2016
@@ -0,0 +1,9 @@
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t2.bc %t.bc
+
+; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t2.bc -exported-symbol=foo -o - | llvm-lto -thinlto-action=internalize -thinlto-module-id=%t.bc - -thinlto-index=%t2.bc -exported-symbol=foo -o - | llvm-dis -o - | FileCheck %s
+
+; CHECK: define weak_odr void @foo()
+define linkonce_odr void @foo() {
+  ret void
+}




More information about the llvm-commits mailing list