[PATCH] D133157: Add -sanitizer-coverage-control-flow

Kostya Serebryany via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 16:11:26 PDT 2022


kcc added a comment.

Cool!
please add the documentation and the run-time test to the same CL.

A'll let Vitaly do the next pass of the code, but will review the documentation.



================
Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1049
+void ModuleSanitizerCoverage::CollectFunctionControlFlow(Function &F) {
+  LLVM_DEBUG(dbgs() << "I am here! " << F.getName() << "\n");
+  SmallVector<Constant *, 32> CFs;
----------------
remove if not needed any more


================
Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1051
+  SmallVector<Constant *, 32> CFs;
+  size_t N;
+  IRBuilder<> IRB(&*F.getEntryBlock().getFirstInsertionPt());
----------------
declare at the first point of use


================
Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1055
+  for (auto &BB: F) {
+    // blockaddress may not be used on function's entry block.
+    if (&BB == &F.getEntryBlock())
----------------
"can not" ?


================
Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1062
+    for (auto SuccBB : successors(&BB)) {
+      if (SuccBB == &F.getEntryBlock())
+        CFs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
----------------
hmmm... is it even possible?


================
Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1071-1072
+    for (auto &Inst: BB) {
+      CallBase *CB = dyn_cast<CallBase>(&Inst);
+      if (CB) {
+        if (!CB->isIndirectCall()) {
----------------
typical LLVM code uses this:
  if (CallBase *CB = ...)) { ...} 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133157/new/

https://reviews.llvm.org/D133157



More information about the llvm-commits mailing list