[PATCH] D133157: Add -sanitizer-coverage-control-flow
Navid Emamdoost via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 1 17:47:47 PDT 2022
Navidem updated this revision to Diff 457466.
Navidem added a comment.
Apply comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133157/new/
https://reviews.llvm.org/D133157
Files:
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -1046,30 +1046,25 @@
}
void ModuleSanitizerCoverage::CollectFunctionControlFlow(Function &F) {
- LLVM_DEBUG(dbgs() << "I am here! " << F.getName() << "\n");
SmallVector<Constant *, 32> CFs;
- size_t N;
IRBuilder<> IRB(&*F.getEntryBlock().getFirstInsertionPt());
for (auto &BB: F) {
- // blockaddress may not be used on function's entry block.
+ // blockaddress can not be used on function's entry block.
if (&BB == &F.getEntryBlock())
CFs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
else
CFs.push_back((Constant *)IRB.CreatePointerCast(BlockAddress::get(&BB), IntptrPtrTy));
for (auto SuccBB : successors(&BB)) {
- if (SuccBB == &F.getEntryBlock())
- CFs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
- else
- CFs.push_back((Constant *)IRB.CreatePointerCast(BlockAddress::get(SuccBB), IntptrPtrTy));
+ assert(SuccBB != &F.getEntryBlock());
+ CFs.push_back((Constant *)IRB.CreatePointerCast(BlockAddress::get(SuccBB), IntptrPtrTy));
}
CFs.push_back((Constant *)IRB.CreateIntToPtr(ConstantInt::get(IntptrTy, 0), IntptrPtrTy));
for (auto &Inst: BB) {
- CallBase *CB = dyn_cast<CallBase>(&Inst);
- if (CB) {
+ if (CallBase *CB = dyn_cast<CallBase>(&Inst)) {
if (!CB->isIndirectCall()) {
auto CalledF = CB->getCalledFunction();
if (CalledF && !CalledF->isIntrinsic())
@@ -1082,7 +1077,7 @@
CFs.push_back((Constant *)IRB.CreateIntToPtr(ConstantInt::get(IntptrTy, 0), IntptrPtrTy));
}
- N = CFs.size();
+ size_t N = CFs.size();
auto CFArray = CreateFunctionLocalArrayInSection(N, F, IntptrPtrTy, SanCovCFsSectionName);
CFArray->setInitializer(ConstantArray::get(ArrayType::get(IntptrPtrTy, N), CFs));
CFArray->setConstant(true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133157.457466.patch
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220902/b912a2ee/attachment.bin>
More information about the llvm-commits
mailing list