diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-05-29 01:43:53 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-05-29 01:43:53 +0000 |
commit | eca0bcfaee4c16fe21552234b0c44dfb978974e5 (patch) | |
tree | 9fbe96765d6f0103bae4bc6330a6655fa8844a67 /lib/CodeGen/CodeGenModule.cpp | |
parent | c3684da1d42df59a6a4c0490f23079c87b1959eb (diff) | |
download | clang-eca0bcfaee4c16fe21552234b0c44dfb978974e5.tar.gz clang-eca0bcfaee4c16fe21552234b0c44dfb978974e5.tar.bz2 clang-eca0bcfaee4c16fe21552234b0c44dfb978974e5.tar.xz |
[ASan] Hoist blacklisting globals from init-order checking to Clang.
Clang knows about the sanitizer blacklist and it makes no sense to
add global to the list of llvm.asan.dynamically_initialized_globals if it
will be blacklisted in the instrumentation pass anyway. Instead, we should
do as much blacklisting as possible (if not all) in the frontend.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209789 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index c55e2310d8..484373b20e 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1878,12 +1878,11 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { EmitCXXGlobalVarDeclInitFunc(D, GV, NeedsGlobalCtor); // If we are compiling with ASan, add metadata indicating dynamically - // initialized globals. - if (SanOpts.Address && NeedsGlobalCtor) { - llvm::Module &M = getModule(); - - llvm::NamedMDNode *DynamicInitializers = - M.getOrInsertNamedMetadata("llvm.asan.dynamically_initialized_globals"); + // initialized (and not blacklisted) globals. + if (SanOpts.Address && NeedsGlobalCtor && + !SanitizerBlacklist->isIn(*GV, "init")) { + llvm::NamedMDNode *DynamicInitializers = TheModule.getOrInsertNamedMetadata( + "llvm.asan.dynamically_initialized_globals"); llvm::Value *GlobalToAdd[] = { GV }; llvm::MDNode *ThisGlobal = llvm::MDNode::get(VMContext, GlobalToAdd); DynamicInitializers->addOperand(ThisGlobal); |