summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-05-29 01:43:53 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-05-29 01:43:53 +0000
commitc054d9813c9c7f8f2c95d78bc171bf761d2e73fc (patch)
tree9b21e42e706ae3c0d79f59470e150c04f1a43206 /clang/lib/CodeGen/CodeGenModule.cpp
parentf375d806355a9d6a17f3fd53673a6257057bc225 (diff)
downloadbcm5719-llvm-c054d9813c9c7f8f2c95d78bc171bf761d2e73fc.tar.gz
bcm5719-llvm-c054d9813c9c7f8f2c95d78bc171bf761d2e73fc.zip
[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. llvm-svn: 209789
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index c55e2310d8c..484373b20ec 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud