[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

llvm-svn: 306770
This commit is contained in:
Shoaib Meenai 2017-06-30 00:07:54 +00:00
parent 53b2cb77cc
commit a2222fa1d2
2 changed files with 13 additions and 0 deletions

View File

@ -64,6 +64,10 @@ static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
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()));
}

View File

@ -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