[PATCH] D34850: [CodeGen] Propagate dllexport to thunks
    Shoaib Meenai via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Thu Jun 29 17:04:40 PDT 2017
    
    
  
smeenai created this revision.
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.
https://reviews.llvm.org/D34850
Files:
  lib/CodeGen/CGVTables.cpp
  test/CodeGenCXX/windows-itanium-dllexport.cpp
Index: test/CodeGenCXX/windows-itanium-dllexport.cpp
===================================================================
--- test/CodeGenCXX/windows-itanium-dllexport.cpp
+++ test/CodeGenCXX/windows-itanium-dllexport.cpp
@@ -53,3 +53,12 @@
 
 // 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
Index: lib/CodeGen/CGVTables.cpp
===================================================================
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -64,6 +64,10 @@
   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()));
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34850.104782.patch
Type: text/x-patch
Size: 1132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170630/e05a3b2f/attachment.bin>
    
    
More information about the cfe-commits
mailing list