From 195a4bc96d32646528785944ad307a5f6f5b99ea Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 16 Nov 2016 16:50:43 +0000 Subject: [PATCH] [sancov] Name the global containing the main source file name If the global name doesn't start with __sancov_gen, ASan will insert unecessary red zones around it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287117 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 6 +++--- test/Instrumentation/SanitizerCoverage/coverage.ll | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index 031effb4060..730e28a7f91 100644 --- a/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -357,9 +357,9 @@ bool SanitizerCoverageModule::runOnModule(Module &M) { // Create variable for module (compilation unit) name Constant *ModNameStrConst = ConstantDataArray::getString(M.getContext(), M.getName(), true); - GlobalVariable *ModuleName = - new GlobalVariable(M, ModNameStrConst->getType(), true, - GlobalValue::PrivateLinkage, ModNameStrConst); + GlobalVariable *ModuleName = new GlobalVariable( + M, ModNameStrConst->getType(), true, GlobalValue::PrivateLinkage, + ModNameStrConst, "__sancov_gen_modname"); if (Options.TracePCGuard) { if (HasSancovGuardsSection) { Function *CtorFunc; diff --git a/test/Instrumentation/SanitizerCoverage/coverage.ll b/test/Instrumentation/SanitizerCoverage/coverage.ll index bc32374e549..a2a92a02c71 100644 --- a/test/Instrumentation/SanitizerCoverage/coverage.ll +++ b/test/Instrumentation/SanitizerCoverage/coverage.ll @@ -49,7 +49,7 @@ entry: ; CHECK1-LABEL: define internal void @sancov.module_ctor ; CHECK1-NOT: ret -; CHECK1: call void @__sanitizer_cov_module_init({{.*}}, i64 2, +; CHECK1: call void @__sanitizer_cov_module_init({{.*}}, i64 2, {{.*}}@__sancov_gen_modname ; CHECK1: ret ; CHECK_WITH_CHECK-LABEL: define void @foo -- 2.40.0