diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-07-15 14:48:06 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-07-15 14:48:06 +0000 |
commit | f9e5dc7d82c98bd3d3588557237a2dda18c57635 (patch) | |
tree | c60286cc5f1d937e07582ab57c30a9664fbb8857 /lib | |
parent | ad6e47665fd86439bc82b861d90767c03cd575aa (diff) | |
download | clang-f9e5dc7d82c98bd3d3588557237a2dda18c57635.tar.gz |
Set comdat when an available_externally thunk is converted to linkonce_odr.
Fixes pr24130.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/CGVTables.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 373009e8bf..7321dbfe34 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -56,6 +56,21 @@ static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD, CGM.setGlobalVisibility(Fn, MD); } +static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk, + llvm::Function *ThunkFn, bool ForVTable, + GlobalDecl GD) { + CGM.setFunctionLinkage(GD, ThunkFn); + CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable, GD, + !Thunk.Return.isEmpty()); + + // Set the right visibility. + const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); + setThunkVisibility(CGM, MD, Thunk, ThunkFn); + + if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker()) + ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName())); +} + #ifndef NDEBUG static bool similar(const ABIArgInfo &infoL, CanQualType typeL, const ABIArgInfo &infoR, CanQualType typeR) { @@ -429,8 +444,7 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk, return; } - // Change the linkage. - CGM.setFunctionLinkage(GD, ThunkFn); + setThunkProperties(CGM, Thunk, ThunkFn, ForVTable, GD); return; } @@ -451,16 +465,7 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk, CodeGenFunction(CGM).generateThunk(ThunkFn, FnInfo, GD, Thunk); } - CGM.setFunctionLinkage(GD, ThunkFn); - CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable, GD, - !Thunk.Return.isEmpty()); - - // Set the right visibility. - const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); - setThunkVisibility(CGM, MD, Thunk, ThunkFn); - - if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker()) - ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName())); + setThunkProperties(CGM, Thunk, ThunkFn, ForVTable, GD); } void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD, |