r306770 - [CodeGen] Propagate dllexport to thunks

Shoaib Meenai via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 17:07:54 PDT 2017


Author: smeenai
Date: Thu Jun 29 17:07:54 2017
New Revision: 306770

URL: http://llvm.org/viewvc/llvm-project?rev=306770&view=rev
Log:
[CodeGen] Propagate dllexport to thunks

Under Windows Itanium, we need to export virtual and non-virtual thunks
if the functions being thunked are exported. These thunks would
previously inherit their dllexport attribute from the declaration, but
r298330 changed declarations to not have dllexport attributes. We
therefore need to add the dllexport attribute to the definition
ourselves now.

Differential Revision: https://reviews.llvm.org/D34850

Modified:
    cfe/trunk/lib/CodeGen/CGVTables.cpp
    cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=306770&r1=306769&r2=306770&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Jun 29 17:07:54 2017
@@ -64,6 +64,10 @@ static void setThunkProperties(CodeGenMo
   const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
   setThunkVisibility(CGM, MD, Thunk, ThunkFn);
 
+  // Propagate dllexport storage.
+  if (MD->hasAttr<DLLExportAttr>())
+    ThunkFn->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+
   if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker())
     ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName()));
 }

Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp?rev=306770&r1=306769&r2=306770&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/windows-itanium-dllexport.cpp Thu Jun 29 17:07:54 2017
@@ -53,3 +53,12 @@ USEMEMFUNC(outer<char>::inner, f)
 
 // CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv
 // CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv
+
+struct base {
+  virtual ~base();
+};
+struct __declspec(dllexport) derived : public virtual base {
+  virtual ~derived() {}
+};
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZTv0_n12_N7derivedD0Ev




More information about the cfe-commits mailing list