[llvm] r311794 - [sanitizer-coverage] extend fsanitize-coverage=pc-table with flags for every PC
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 25 12:29:48 PDT 2017
Author: kcc
Date: Fri Aug 25 12:29:47 2017
New Revision: 311794
URL: http://llvm.org/viewvc/llvm-project?rev=311794&view=rev
Log:
[sanitizer-coverage] extend fsanitize-coverage=pc-table with flags for every PC
Modified:
llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/trunk/test/Instrumentation/SanitizerCoverage/pc-table.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=311794&r1=311793&r2=311794&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Fri Aug 25 12:29:47 2017
@@ -389,13 +389,13 @@ bool SanitizerCoverageModule::runOnModul
Ctor = CreateInitCallsForSections(M, SanCov8bitCountersInitName, Int8PtrTy,
SanCovCountersSectionName);
if (Ctor && Options.PCTable) {
- auto SecStartEnd = CreateSecStartEnd(M, SanCovPCsSectionName, Int8PtrTy);
+ auto SecStartEnd = CreateSecStartEnd(M, SanCovPCsSectionName, IntptrPtrTy);
Function *InitFunction = declareSanitizerInitFunction(
- M, SanCovPCsInitName, {Int8PtrTy, Int8PtrTy});
+ M, SanCovPCsInitName, {IntptrPtrTy, IntptrPtrTy});
IRBuilder<> IRBCtor(Ctor->getEntryBlock().getTerminator());
IRBCtor.CreateCall(InitFunction,
- {IRB.CreatePointerCast(SecStartEnd.first, Int8PtrTy),
- IRB.CreatePointerCast(SecStartEnd.second, Int8PtrTy)});
+ {IRB.CreatePointerCast(SecStartEnd.first, IntptrPtrTy),
+ IRB.CreatePointerCast(SecStartEnd.second, IntptrPtrTy)});
}
return true;
}
@@ -545,17 +545,24 @@ void SanitizerCoverageModule::CreatePCAr
ArrayRef<BasicBlock *> AllBlocks) {
size_t N = AllBlocks.size();
assert(N);
- SmallVector<Constant *, 16> PCs;
+ SmallVector<Constant *, 32> PCs;
IRBuilder<> IRB(&*F.getEntryBlock().getFirstInsertionPt());
- for (size_t i = 0; i < N; i++)
- if (&F.getEntryBlock() == AllBlocks[i])
- PCs.push_back((Constant *)IRB.CreatePointerCast(&F, Int8PtrTy));
- else
- PCs.push_back(BlockAddress::get(AllBlocks[i]));
- FunctionPCsArray =
- CreateFunctionLocalArrayInSection(N, F, Int8PtrTy, SanCovPCsSectionName);
+ for (size_t i = 0; i < N; i++) {
+ if (&F.getEntryBlock() == AllBlocks[i]) {
+ PCs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
+ PCs.push_back((Constant *)IRB.CreateIntToPtr(
+ ConstantInt::get(IntptrTy, 1), IntptrPtrTy));
+ } else {
+ PCs.push_back((Constant *)IRB.CreatePointerCast(
+ BlockAddress::get(AllBlocks[i]), IntptrPtrTy));
+ PCs.push_back((Constant *)IRB.CreateIntToPtr(
+ ConstantInt::get(IntptrTy, 0), IntptrPtrTy));
+ }
+ }
+ FunctionPCsArray = CreateFunctionLocalArrayInSection(N * 2, F, IntptrPtrTy,
+ SanCovPCsSectionName);
FunctionPCsArray->setInitializer(
- ConstantArray::get(ArrayType::get(Int8PtrTy, N), PCs));
+ ConstantArray::get(ArrayType::get(IntptrPtrTy, N * 2), PCs));
FunctionPCsArray->setConstant(true);
// We don't reference the PCs array in any of our runtime functions, so we
Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/pc-table.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/pc-table.ll?rev=311794&r1=311793&r2=311794&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/pc-table.ll (original)
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/pc-table.ll Fri Aug 25 12:29:47 2017
@@ -17,7 +17,7 @@ entry:
ret void
}
-; CHECK: private constant [3 x i8*] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}], section "__sancov_pcs", align 8
+; CHECK: private constant [6 x i64*] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}], section "__sancov_pcs", align 8
; CHECK: define internal void @sancov.module_ctor
; CHECK: call void @__sanitizer_cov
; CHECK: call void @__sanitizer_cov_pcs_init
More information about the llvm-commits
mailing list