<div>What about the import side?</div><div><br><div class="gmail_quote"><div>On Mon, Jul 3, 2017 at 10:37 PM Shoaib Meenai via Phabricator via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">smeenai created this revision.<br>
<br>
Under Windows Itanium, we need to export virtual and non-virtual thunks<br>
if the functions being thunked are exported. These thunks would<br>
previously inherit their dllexport attribute from the declaration, but<br>
r298330 changed declarations to not have dllexport attributes. We<br>
therefore need to add the dllexport attribute to the definition<br>
ourselves now. This is consistent with MinGW GCC's behavior.<br>
<br>
This redoes r306770 but limits the logic to Itanium. MicrosoftCXXABI's<br>
setThunkLinkage ensures that thunks aren't exported under that ABI, so<br>
I'm handling this in ItaniumCXXABI's setThunkLinkage for symmetry.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D34972" rel="noreferrer" target="_blank">https://reviews.llvm.org/D34972</a><br>
<br>
Files:<br>
  lib/CodeGen/ItaniumCXXABI.cpp<br>
  test/CodeGenCXX/dllexport-vtable-thunks.cpp<br>
<br>
<br>
Index: test/CodeGenCXX/dllexport-vtable-thunks.cpp<br>
===================================================================<br>
--- /dev/null<br>
+++ test/CodeGenCXX/dllexport-vtable-thunks.cpp<br>
@@ -0,0 +1,23 @@<br>
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -fdeclspec -emit-llvm -o - %s | FileCheck %s<br>
+// RUN: %clang_cc1 -triple x86_64-windows-itanium -fdeclspec -emit-llvm -o - %s | FileCheck %s<br>
+<br>
+struct __declspec(dllexport) A {<br>
+  virtual void m();<br>
+};<br>
+struct __declspec(dllexport) B {<br>
+  virtual void m();<br>
+};<br>
+struct __declspec(dllexport) C : A, B {<br>
+  virtual void m();<br>
+};<br>
+void C::m() {}<br>
+// CHECK: define dllexport void @_ZThn8_N1C1mEv<br>
+<br>
+struct Base {<br>
+  virtual void m();<br>
+};<br>
+struct __declspec(dllexport) Derived : virtual Base {<br>
+  virtual void m();<br>
+};<br>
+void Derived::m() {}<br>
+// CHECK: define dllexport void @_ZTv0_n24_N7Derived1mEv<br>
Index: lib/CodeGen/ItaniumCXXABI.cpp<br>
===================================================================<br>
--- lib/CodeGen/ItaniumCXXABI.cpp<br>
+++ lib/CodeGen/ItaniumCXXABI.cpp<br>
@@ -284,6 +284,11 @@<br>
     // linkage together with vtables when needed.<br>
     if (ForVTable && !Thunk->hasLocalLinkage())<br>
       Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);<br>
+<br>
+    // Propagate dllexport storage.<br>
+    const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());<br>
+    if (MD->hasAttr<DLLExportAttr>())<br>
+      Thunk->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);<br>
   }<br>
<br>
   llvm::Value *performThisAdjustment(CodeGenFunction &CGF, Address This,<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>