diff options
author | Reid Kleckner <rnk@google.com> | 2018-03-16 19:40:50 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2018-03-16 19:40:50 +0000 |
commit | ae9b07011140037c364e5efa2bb3ff422163d5b5 (patch) | |
tree | 3388ccca7a0b75251bffb10bdd35ed71bdac9575 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 5ba2fe3720c51c1ea5740c32c525d48a64105626 (diff) | |
download | bcm5719-llvm-ae9b07011140037c364e5efa2bb3ff422163d5b5.tar.gz bcm5719-llvm-ae9b07011140037c364e5efa2bb3ff422163d5b5.zip |
[MS] Always use base dtors in place of complete/vbase dtors when possible
Summary:
Previously we tried too hard to uphold the fiction that destructor
variants work like they do on Itanium throughout the ABI-neutral parts
of clang. This lead to MS C++ ABI incompatiblities and other bugs. Now,
-mconstructor-aliases will no longer control this ABI detail, and clang
-cc1's LLVM IR output will be this much closer to the clang driver's.
Based on a patch by Zahira Ammarguellat:
https://reviews.llvm.org/D39063
I've tried to move the logic that Zahira added into MicrosoftCXXABI.cpp.
There is only one ABI-specific detail sticking out, and that is in
CodeGenModule::getAddrOfCXXStructor, where we collapse complete dtors to
base dtors in the MS ABI.
This fixes PR32990.
Reviewers: erichkeane, zahiraam, majnemer, rjmccall
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D44505
llvm-svn: 327732
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3c503eb66fa..cb1bfc143bf 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -786,12 +786,10 @@ void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV) const { void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl GD) const { const auto *D = dyn_cast<NamedDecl>(GD.getDecl()); + // C++ destructors have a few C++ ABI specific special cases. if (const auto *Dtor = dyn_cast_or_null<CXXDestructorDecl>(D)) { - if (getCXXABI().useThunkForDtorVariant(Dtor, GD.getDtorType())) { - // Don't dllexport/import destructor thunks. - GV->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass); - return; - } + getCXXABI().setCXXDestructorDLLStorage(GV, Dtor, GD.getDtorType()); + return; } setDLLImportDLLExport(GV, D); } @@ -1074,14 +1072,8 @@ CodeGenModule::getFunctionLinkage(GlobalDecl GD) { GVALinkage Linkage = getContext().GetGVALinkageForFunction(D); - if (isa<CXXDestructorDecl>(D) && - getCXXABI().useThunkForDtorVariant(cast<CXXDestructorDecl>(D), - GD.getDtorType())) { - // Destructor variants in the Microsoft C++ ABI are always internal or - // linkonce_odr thunks emitted on an as-needed basis. - return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage - : llvm::GlobalValue::LinkOnceODRLinkage; - } + if (const auto *Dtor = dyn_cast<CXXDestructorDecl>(D)) + return getCXXABI().getCXXDestructorLinkage(Linkage, Dtor, GD.getDtorType()); if (isa<CXXConstructorDecl>(D) && cast<CXXConstructorDecl>(D)->isInheritingConstructor() && |