summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-09-09 05:30:13 +0000
committerKostya Serebryany <kcc@google.com>2017-09-09 05:30:13 +0000
commit4192b9631372b5a43c256fcaec98e6aaa9975d05 (patch)
tree9eadbc5e4816adc6f10125a3874331e358275d6a /llvm/lib
parent415a60f3035bdf36d2a93003995a50d8ef68eacb (diff)
downloadbcm5719-llvm-4192b9631372b5a43c256fcaec98e6aaa9975d05.tar.gz
bcm5719-llvm-4192b9631372b5a43c256fcaec98e6aaa9975d05.zip
[sanitizer-coverage] call appendToUsed once per module, not once per function (which is too slow)
llvm-svn: 312855
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
index a3128fd089d..d950e2e730f 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -242,6 +242,7 @@ private:
GlobalVariable *FunctionGuardArray; // for trace-pc-guard.
GlobalVariable *Function8bitCounterArray; // for inline-8bit-counters.
GlobalVariable *FunctionPCsArray; // for pc-table.
+ SmallVector<GlobalValue *, 20> GlobalsToAppendToUsed;
SanitizerCoverageOptions Options;
};
@@ -400,6 +401,10 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
{IRB.CreatePointerCast(SecStartEnd.first, IntptrPtrTy),
IRB.CreatePointerCast(SecStartEnd.second, IntptrPtrTy)});
}
+ // We don't reference these arrays directly in any of our runtime functions,
+ // so we need to prevent them from being dead stripped.
+ if (TargetTriple.isOSBinFormatMachO())
+ appendToUsed(M, GlobalsToAppendToUsed);
return true;
}
@@ -579,25 +584,20 @@ SanitizerCoverageModule::CreatePCArray(Function &F,
void SanitizerCoverageModule::CreateFunctionLocalArrays(
Function &F, ArrayRef<BasicBlock *> AllBlocks) {
- SmallVector<GlobalValue *, 3> LocalArrays;
if (Options.TracePCGuard) {
FunctionGuardArray = CreateFunctionLocalArrayInSection(
AllBlocks.size(), F, Int32Ty, SanCovGuardsSectionName);
- LocalArrays.push_back(FunctionGuardArray);
+ GlobalsToAppendToUsed.push_back(FunctionGuardArray);
}
if (Options.Inline8bitCounters) {
Function8bitCounterArray = CreateFunctionLocalArrayInSection(
AllBlocks.size(), F, Int8Ty, SanCovCountersSectionName);
- LocalArrays.push_back(Function8bitCounterArray);
+ GlobalsToAppendToUsed.push_back(Function8bitCounterArray);
}
if (Options.PCTable) {
FunctionPCsArray = CreatePCArray(F, AllBlocks);
- LocalArrays.push_back(FunctionPCsArray);
+ GlobalsToAppendToUsed.push_back(FunctionPCsArray);
}
-
- // We don't reference these arrays directly in any of our runtime functions,
- // so we need to prevent them from being dead stripped.
- appendToUsed(*F.getParent(), LocalArrays);
}
bool SanitizerCoverageModule::InjectCoverage(Function &F,
OpenPOWER on IntegriCloud