<div dir="ltr">Hey Lang,<br><br>Seem to recall you discussing this issue coming up in Orc recently too? Hopefully there's some way to refactor/reuse the logic between Orc lazy module splitting and ThinLTO splitting?<br><br>- Dave</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 4, 2015 at 8:01 AM, Teresa Johnson via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: tejohnson<br>
Date: Wed Nov 4 10:01:16 2015<br>
New Revision: 252054<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=252054&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=252054&view=rev</a><br>
Log:<br>
[ThinLTO] Always set linkage type to external when converting alias<br>
<br>
When converting an alias to a non-alias when the aliasee is not<br>
imported, ensure that the linkage type is set to external so that it is<br>
a valid linkage type. Added a test case that exposed this issue.<br>
<br>
Modified:<br>
llvm/trunk/lib/Linker/LinkModules.cpp<br>
llvm/trunk/test/Linker/funcimport.ll<br>
<br>
Modified: llvm/trunk/lib/Linker/LinkModules.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=252054&r1=252053&r2=252054&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=252054&r1=252053&r2=252054&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)<br>
+++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Nov 4 10:01:16 2015<br>
@@ -841,10 +841,12 @@ GlobalValue *ModuleLinker::copyGlobalAli<br>
assert(F);<br>
NewGV = copyFunctionProto(TypeMap, F);<br>
}<br>
- // Set the linkage to ExternalWeak, see also comments in<br>
- // ModuleLinker::getLinkage.<br>
+ // Set the linkage to External or ExternalWeak (see comments in<br>
+ // ModuleLinker::getLinkage for why WeakAny is converted to ExternalWeak).<br>
if (SGA->hasWeakAnyLinkage())<br>
NewGV->setLinkage(GlobalValue::ExternalWeakLinkage);<br>
+ else<br>
+ NewGV->setLinkage(GlobalValue::ExternalLinkage);<br>
// Don't attempt to link body, needs to be a declaration.<br>
DoNotLinkFromSource.insert(SGA);<br>
return NewGV;<br>
<br>
Modified: llvm/trunk/test/Linker/funcimport.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/funcimport.ll?rev=252054&r1=252053&r2=252054&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/funcimport.ll?rev=252054&r1=252053&r2=252054&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Linker/funcimport.ll (original)<br>
+++ llvm/trunk/test/Linker/funcimport.ll Wed Nov 4 10:01:16 2015<br>
@@ -14,11 +14,16 @@<br>
<br>
; Ensure that both weak alias to an imported function and strong alias to a<br>
; non-imported function are correctly turned into declarations.<br>
+; Also ensures that alias to a linkonce function is turned into a declaration<br>
+; and that the associated linkonce function is not in the output, as it is<br>
+; lazily linked and never referenced/materialized.<br>
; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc -import=globalfunc1:%t.bc -S | FileCheck %s --check-prefix=IMPORTGLOB1<br>
; IMPORTGLOB1: define available_externally void @globalfunc1<br>
; IMPORTGLOB1: declare void @globalfunc2<br>
; IMPORTGLOB1: declare extern_weak void @weakalias<br>
; IMPORTGLOB1: declare void @analias<br>
+; IMPORTGLOB1: declare void @linkoncealias<br>
+; IMPORTGLOB1-NOT: @linkoncefunc<br>
<br>
; Ensure that weak alias to a non-imported function is correctly<br>
; turned into a declaration, but that strong alias to an imported function<br>
@@ -91,6 +96,7 @@<br>
<br>
@weakalias = weak alias void (...), bitcast (void ()* @globalfunc1 to void (...)*)<br>
@analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)<br>
+@linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)*)<br>
<br>
define void @globalfunc1() #0 {<br>
entry:<br>
@@ -101,6 +107,11 @@ define void @globalfunc2() #0 {<br>
entry:<br>
ret void<br>
}<br>
+<br>
+define linkonce_odr void @linkoncefunc() #0 {<br>
+entry:<br>
+ ret void<br>
+}<br>
<br>
define i32 @referencestatics(i32 %i) #0 {<br>
entry:<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>