diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2018-08-21 17:24:06 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2018-08-21 17:24:06 +0000 |
commit | 5a559e64a919dfdbc9d97af2a3529a2c9f555230 (patch) | |
tree | 6dbe891715fe23defb265c1df486e9f097ada5bb /clang/lib/CodeGen/MicrosoftCXXABI.cpp | |
parent | 7d1790868f289ca7831c2175463899dbe2bdd5e3 (diff) | |
download | bcm5719-llvm-5a559e64a919dfdbc9d97af2a3529a2c9f555230.tar.gz bcm5719-llvm-5a559e64a919dfdbc9d97af2a3529a2c9f555230.zip |
Add a new flag and attributes to control static destructor registration
This commit adds the flag -fno-c++-static-destructors and the attributes
[[clang::no_destroy]] and [[clang::always_destroy]]. no_destroy specifies that a
specific static or thread duration variable shouldn't have it's destructor
registered, and is the default in -fno-c++-static-destructors mode.
always_destroy is the opposite, and is the default in -fc++-static-destructors
mode.
A variable whose destructor is disabled (either because of
-fno-c++-static-destructors or [[clang::no_destroy]]) doesn't count as a use of
the destructor, so we don't do any access checking or mark it referenced. We
also don't emit -Wexit-time-destructors for these variables.
rdar://21734598
Differential revision: https://reviews.llvm.org/D50994
llvm-svn: 340306
Diffstat (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 059adb78ca3..968c171c71b 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -2240,6 +2240,9 @@ static void emitGlobalDtorWithTLRegDtor(CodeGenFunction &CGF, const VarDecl &VD, void MicrosoftCXXABI::registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D, llvm::Constant *Dtor, llvm::Constant *Addr) { + if (D.isNoDestroy(CGM.getContext())) + return; + if (D.getTLSKind()) return emitGlobalDtorWithTLRegDtor(CGF, D, Dtor, Addr); |