[PATCH] D133173: Apply comments

Navid Emamdoost via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 17:46:01 PDT 2022


Navidem created this revision.
Herald added subscribers: Enna1, hiraditya.
Herald added a project: All.
Navidem requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133173

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: D133173.457465.patch
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220902/df999b9a/attachment.bin>


More information about the llvm-commits mailing list