[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
This commit is contained in:
Alexey Samsonov
2014-05-29 01:43:53 +00:00
parent f375d80635
commit c054d9813c
2 changed files with 14 additions and 6 deletions

View File

@@ -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);