[llvm-branch-commits] [llvm-branch] r227344 - Backport r226026 and r226031 to 3.6.

Rafael Espindola rafael.espindola at gmail.com
Wed Jan 28 10:54:17 PST 2015


Author: rafael
Date: Wed Jan 28 12:54:17 2015
New Revision: 227344

URL: http://llvm.org/viewvc/llvm-project?rev=227344&view=rev
Log:
Backport r226026 and r226031 to 3.6.

This fixes pr22351.

Original messages:

r226026:
Fix handling of extern_weak. This was broken by r225983

r226031:
Fix linking of shared libraries.

In shared libraries the plugin can see non-weak declarations that are still
undefined.

Modified:
    llvm/branches/release_36/test/tools/gold/emit-llvm.ll
    llvm/branches/release_36/tools/gold/gold-plugin.cpp

Modified: llvm/branches/release_36/test/tools/gold/emit-llvm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/test/tools/gold/emit-llvm.ll?rev=227344&r1=227343&r2=227344&view=diff
==============================================================================
--- llvm/branches/release_36/test/tools/gold/emit-llvm.ll (original)
+++ llvm/branches/release_36/test/tools/gold/emit-llvm.ll Wed Jan 28 12:54:17 2015
@@ -21,6 +21,11 @@
 
 target triple = "x86_64-unknown-linux-gnu"
 
+ at g7 = extern_weak global i32
+; CHECK-DAG: @g7 = extern_weak global i32
+
+ at g8 = external global i32
+
 ; CHECK: define internal void @f1()
 ; OPT-NOT: @f1
 define hidden void @f1() {
@@ -62,6 +67,13 @@ define linkonce_odr void @f6() unnamed_a
 }
 @g6 = global void()* @f6
 
+define i32* @f7() {
+  ret i32* @g7
+}
+
+define i32* @f8() {
+  ret i32* @g8
+}
 
 ; API: f1 PREVAILING_DEF_IRONLY
 ; API: f2 PREVAILING_DEF_IRONLY
@@ -69,5 +81,9 @@ define linkonce_odr void @f6() unnamed_a
 ; API: f4 PREVAILING_DEF_IRONLY_EXP
 ; API: f5 PREVAILING_DEF_IRONLY_EXP
 ; API: f6 PREVAILING_DEF_IRONLY_EXP
+; API: f7 PREVAILING_DEF_IRONLY_EXP
+; API: f8 PREVAILING_DEF_IRONLY_EXP
+; API: g7 UNDEF
+; API: g8 UNDEF
 ; API: g5 PREVAILING_DEF_IRONLY_EXP
 ; API: g6 PREVAILING_DEF_IRONLY_EXP

Modified: llvm/branches/release_36/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/tools/gold/gold-plugin.cpp?rev=227344&r1=227343&r2=227344&view=diff
==============================================================================
--- llvm/branches/release_36/tools/gold/gold-plugin.cpp (original)
+++ llvm/branches/release_36/tools/gold/gold-plugin.cpp Wed Jan 28 12:54:17 2015
@@ -633,8 +633,10 @@ getModuleForFile(LLVMContext &Context, c
       break;
 
     case LDPR_UNDEF:
-      assert(GV->hasComdat());
-      Drop.insert(GV);
+      if (!GV->isDeclarationForLinker()) {
+        assert(GV->hasComdat());
+        Drop.insert(GV);
+      }
       break;
 
     case LDPR_PREVAILING_DEF_IRONLY: {





More information about the llvm-branch-commits mailing list