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())); }
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())); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits