summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2017-08-29 00:11:05 +0000
committerJustin Bogner <mail@justinbogner.com>2017-08-29 00:11:05 +0000
commitf1a54a47b08df197b037aef97d04d87b5997f221 (patch)
tree23554dec69d9d6e5923428553eb6c432c600fc5b /llvm/lib
parent24bc6a4c4f271e28eb2d983a492e28e9c428e894 (diff)
downloadbcm5719-llvm-f1a54a47b08df197b037aef97d04d87b5997f221.tar.gz
bcm5719-llvm-f1a54a47b08df197b037aef97d04d87b5997f221.zip
[sanitizer-coverage] Mark the guard and 8-bit counter arrays as used
In r311742 we marked the PCs array as used so it wouldn't be dead stripped, but left the guard and 8-bit counters arrays alone since these are referenced by the coverage instrumentation. This doesn't quite work if we want the indices of the PCs array to match the other arrays though, since elements can still end up being dead and disappear. Instead, we mark all three of these arrays as used so that they'll be consistent with one another. llvm-svn: 311959
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
index ffe35f57db7..0f2e7772c76 100644
--- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -566,23 +566,30 @@ SanitizerCoverageModule::CreatePCArray(Function &F,
ConstantArray::get(ArrayType::get(IntptrPtrTy, N * 2), PCs));
PCArray->setConstant(true);
- // We don't reference the PCs array in any of our runtime functions, so we
- // need to prevent it from being dead stripped.
- appendToUsed(*F.getParent(), {PCArray});
-
return PCArray;
}
void SanitizerCoverageModule::CreateFunctionLocalArrays(
Function &F, ArrayRef<BasicBlock *> AllBlocks) {
- if (Options.TracePCGuard)
+ SmallVector<GlobalValue *, 3> LocalArrays;
+ if (Options.TracePCGuard) {
FunctionGuardArray = CreateFunctionLocalArrayInSection(
AllBlocks.size(), F, Int32Ty, SanCovGuardsSectionName);
- if (Options.Inline8bitCounters)
+ LocalArrays.push_back(FunctionGuardArray);
+ }
+ if (Options.Inline8bitCounters) {
Function8bitCounterArray = CreateFunctionLocalArrayInSection(
AllBlocks.size(), F, Int8Ty, SanCovCountersSectionName);
- if (Options.PCTable)
+ LocalArrays.push_back(Function8bitCounterArray);
+ }
+ if (Options.PCTable) {
FunctionPCsArray = CreatePCArray(F, AllBlocks);
+ LocalArrays.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