[llvm] r262139 - Revert "[sancov] do not instrument nodes that are full pre-dominators"

Renato Golin via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 27 06:19:20 PST 2016


Author: rengolin
Date: Sat Feb 27 08:19:19 2016
New Revision: 262139

URL: http://llvm.org/viewvc/llvm-project?rev=262139&view=rev
Log:
Revert "[sancov] do not instrument nodes that are full pre-dominators"

This reverts commit r262103, as it broke all ARM and AArch64 bots.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=262139&r1=262138&r2=262139&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Sat Feb 27 08:19:19 2016
@@ -31,7 +31,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/EHPersonalities.h"
-#include "llvm/Analysis/PostDominators.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/DataLayout.h"
@@ -160,12 +159,8 @@ class SanitizerCoverageModule : public M
   const char *getPassName() const override {
     return "SanitizerCoverageModule";
   }
-  void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<DominatorTreeWrapperPass>();
-    AU.addRequired<PostDominatorTreeWrapperPass>();
-  }
 
-private:
+ private:
   void InjectCoverageForIndirectCalls(Function &F,
                                       ArrayRef<Instruction *> IndirCalls);
   void InjectTraceForCmp(Function &F, ArrayRef<Instruction *> CmpTraceTargets);
@@ -312,24 +307,20 @@ bool SanitizerCoverageModule::runOnModul
   return true;
 }
 
-static bool shouldInstrumentBlock(const BasicBlock *BB, const DominatorTree *DT,
-                                  const PostDominatorTree *PDT) {
+static bool shouldInstrumentBlock(const BasicBlock *BB,
+                                  const DominatorTree *DT) {
   if (!ClPruneBlocks)
     return true;
+  if (succ_begin(BB) == succ_end(BB))
+    return true;
 
   // Check if BB dominates all its successors.
-  bool DominatesAll = succ_begin(BB) != succ_end(BB);
   for (const BasicBlock *SUCC : make_range(succ_begin(BB), succ_end(BB))) {
-    DominatesAll &= DT->dominates(BB, SUCC);
+    if (!DT->dominates(BB, SUCC))
+      return true;
   }
 
-  // Check if BB pre-dominates all predecessors.
-  bool PreDominatesAll = pred_begin(BB) != pred_end(BB);
-  for (const BasicBlock *PRED : make_range(pred_begin(BB), pred_end(BB))) {
-    PreDominatesAll &= PDT->dominates(BB, PRED);
-  }
-
-  return !(DominatesAll || PreDominatesAll);
+  return false;
 }
 
 bool SanitizerCoverageModule::runOnFunction(Function &F) {
@@ -349,12 +340,10 @@ bool SanitizerCoverageModule::runOnFunct
   SmallVector<Instruction*, 8> CmpTraceTargets;
   SmallVector<Instruction*, 8> SwitchTraceTargets;
 
-  DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
-  PostDominatorTree *PDT =
-      &getAnalysis<PostDominatorTreeWrapperPass>(F).getPostDomTree();
-
+  DominatorTree DT;
+  DT.recalculate(F);
   for (auto &BB : F) {
-    if (shouldInstrumentBlock(&BB, DT, PDT))
+    if (shouldInstrumentBlock(&BB, &DT))
       BlocksToInstrument.push_back(&BB);
     for (auto &Inst : BB) {
       if (Options.IndirectCalls) {




More information about the llvm-commits mailing list