<div dir="ltr">LGTM</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 17, 2015 at 10:15 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">Hi ruiu,<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10530&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=gIDAz9kvcjqJTtoUb3gRy47RcfzLLK1chxSeUDXthbY&s=L6JgiNDZWrJc_ROTXLpxQ_YGtcmT0kKUq-Z2gXk2HyA&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D10530</a><br>
<br>
Files:<br>
  COFF/InputFiles.cpp<br>
  test/COFF/Inputs/export.ll<br>
  test/COFF/dll.test<br>
<br>
Index: COFF/InputFiles.cpp<br>
===================================================================<br>
--- COFF/InputFiles.cpp<br>
+++ COFF/InputFiles.cpp<br>
@@ -269,6 +269,14 @@<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>
Index: test/COFF/Inputs/export.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/COFF/Inputs/export.ll<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>
Index: test/COFF/dll.test<br>
===================================================================<br>
--- test/COFF/dll.test<br>
+++ test/COFF/dll.test<br>
@@ -10,10 +10,26 @@<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>
EMAIL PREFERENCES<br>
  <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_settings_panel_emailpreferences_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=gIDAz9kvcjqJTtoUb3gRy47RcfzLLK1chxSeUDXthbY&s=g1kWiPmobbd6_60edozO_cJouZm-07Ur3RLQbLrqXgY&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
</blockquote></div><br></div>