<div dir="ltr">On second thought, is this something the user of libLTO should do? It feels something that libLTO itself should do.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 17, 2015 at 10:22 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: pcc<br>
Date: Thu Jun 18 00:22:15 2015<br>
New Revision: 239994<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D239994-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PsPVfbqlUvi4ICg8UUfXW_MZ_xp4HZd16XZlSuP2cvI&s=4_lJgwOfEZr3TxEoGP3tN8dyPkiVmgDPJ0jYS17CcT0&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=239994&view=rev</a><br>
Log:<br>
COFF: Implement DLL symbol exports for bitcode files.<br>
<br>
Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10530&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PsPVfbqlUvi4ICg8UUfXW_MZ_xp4HZd16XZlSuP2cvI&s=DVKC4o6Xb5tlBd9lclI6wtsWCI9KQLa-IcNp1utbyqw&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D10530</a><br>
<br>
Added:<br>
lld/trunk/test/COFF/Inputs/export.ll<br>
Modified:<br>
lld/trunk/COFF/InputFiles.cpp<br>
lld/trunk/test/COFF/dll.test<br>
<br>
Modified: lld/trunk/COFF/InputFiles.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_COFF_InputFiles.cpp-3Frev-3D239994-26r1-3D239993-26r2-3D239994-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PsPVfbqlUvi4ICg8UUfXW_MZ_xp4HZd16XZlSuP2cvI&s=RFhKjfvbBzujwSN_pXkR4jURGzDTIVQ-ab0DxfqKw9o&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=239994&r1=239993&r2=239994&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/InputFiles.cpp (original)<br>
+++ lld/trunk/COFF/InputFiles.cpp Thu Jun 18 00:22:15 2015<br>
@@ -269,6 +269,14 @@ std::error_code BitcodeFile::parse() {<br>
bool Replaceable = (SymbolDef == LTO_SYMBOL_DEFINITION_TENTATIVE ||<br>
(Attrs & LTO_SYMBOL_COMDAT));<br>
SymbolBodies.push_back(new (Alloc) DefinedBitcode(SymName, Replaceable));<br>
+<br>
+ const llvm::GlobalValue *GV = M->getSymbolGV(I);<br>
+ if (GV && GV->hasDLLExportStorageClass()) {<br>
+ Directives += " /export:";<br>
+ Directives += SymName;<br>
+ if (!GV->getValueType()->isFunctionTy())<br>
+ Directives += ",data";<br>
+ }<br>
}<br>
}<br>
<br>
<br>
Added: lld/trunk/test/COFF/Inputs/export.ll<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_COFF_Inputs_export.ll-3Frev-3D239994-26view-3Dauto&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PsPVfbqlUvi4ICg8UUfXW_MZ_xp4HZd16XZlSuP2cvI&s=vNYor1Uc06uzuVQ3exyewHrP8sEOLFxWCTxa-P-2U_4&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/export.ll?rev=239994&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/test/COFF/Inputs/export.ll (added)<br>
+++ lld/trunk/test/COFF/Inputs/export.ll Thu Jun 18 00:22:15 2015<br>
@@ -0,0 +1,18 @@<br>
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"<br>
+target triple = "x86_64-pc-windows-msvc"<br>
+<br>
+define void @_DllMainCRTStartup() {<br>
+ ret void<br>
+}<br>
+<br>
+define void @exportfn1() {<br>
+ ret void<br>
+}<br>
+<br>
+define void @exportfn2() {<br>
+ ret void<br>
+}<br>
+<br>
+define dllexport void @exportfn3() {<br>
+ ret void<br>
+}<br>
<br>
Modified: lld/trunk/test/COFF/dll.test<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_COFF_dll.test-3Frev-3D239994-26r1-3D239993-26r2-3D239994-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PsPVfbqlUvi4ICg8UUfXW_MZ_xp4HZd16XZlSuP2cvI&s=pJAALFNnYiO_i4-nagwcA2IfaMLE-ZaFEMney0zpKU0&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/dll.test?rev=239994&r1=239993&r2=239994&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/COFF/dll.test (original)<br>
+++ lld/trunk/test/COFF/dll.test Thu Jun 18 00:22:15 2015<br>
@@ -10,10 +10,26 @@ EXPORT: Ordinal RVA Name<br>
EXPORT-NEXT: 0 0<br>
EXPORT-NEXT: 1 0x1008 exportfn1<br>
EXPORT-NEXT: 2 0x1010 exportfn2<br>
+EXPORT-NEXT: 3 0x1010 exportfn3<br>
+<br>
+# RUN: llvm-as -o %t.lto.obj %p/Inputs/export.ll<br>
+# RUN: lld -flavor link2 /out:%t.lto.dll /dll %t.lto.obj /export:exportfn1 /export:exportfn2<br>
+# RUN: llvm-objdump -p %t.lto.dll | FileCheck -check-prefix=EXPORT-LTO %s<br>
+<br>
+EXPORT-LTO: Export Table:<br>
+EXPORT-LTO: DLL name: dll.test.tmp.lto.dll<br>
+EXPORT-LTO: Ordinal RVA Name<br>
+EXPORT-LTO-NEXT: 0 0<br>
+EXPORT-LTO-NEXT: 1 0x1010 exportfn1<br>
+EXPORT-LTO-NEXT: 2 0x1020 exportfn2<br>
+EXPORT-LTO-NEXT: 3 0x1030 exportfn3<br>
<br>
# RUN: yaml2obj < %p/Inputs/import.yaml > %t2.obj<br>
# RUN: lld -flavor link2 /out:%t2.exe %t2.obj %t.lib<br>
# RUN: llvm-readobj -coff-imports %t2.exe | FileCheck -check-prefix=IMPORT %s<br>
<br>
+# RUN: lld -flavor link2 /out:%t2.lto.exe %t2.obj %t.lto.lib<br>
+# RUN: llvm-readobj -coff-imports %t2.lto.exe | FileCheck -check-prefix=IMPORT %s<br>
+<br>
IMPORT: Symbol: exportfn1<br>
IMPORT: Symbol: exportfn2<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>