[IPT] Add a statistic to track instructions scanned to answer queries
authorPhilip Reames <listmail@philipreames.com>
Fri, 8 Oct 2021 17:49:54 +0000 (10:49 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 8 Oct 2021 17:59:35 +0000 (10:59 -0700)
I'm planning some changes to the invalidation mechanism here, and having a concrete mechanism to track progress is key.

llvm/lib/Analysis/InstructionPrecedenceTracking.cpp

index e22655510666a2ce5ad262487354c2ad708e1e73..9fee57c54b85867e488b6a00f89ef66400197dba 100644 (file)
 
 #include "llvm/Analysis/InstructionPrecedenceTracking.h"
 #include "llvm/Analysis/ValueTracking.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/IR/PatternMatch.h"
 #include "llvm/Support/CommandLine.h"
 
 using namespace llvm;
 
+#define DEBUG_TYPE "ipt"
+STATISTIC(NumInstScanned, "Number of insts scanned while updating ibt");
+
 #ifndef NDEBUG
 static cl::opt<bool> ExpensiveAsserts(
     "ipt-expensive-asserts",
@@ -64,11 +68,13 @@ bool InstructionPrecedenceTracking::isPreceededBySpecialInstruction(
 
 void InstructionPrecedenceTracking::fill(const BasicBlock *BB) {
   FirstSpecialInsts.erase(BB);
-  for (auto &I : *BB)
+  for (auto &I : *BB) {
+    NumInstScanned++;
     if (isSpecialInstruction(&I)) {
       FirstSpecialInsts[BB] = &I;
       return;
     }
+  }
 
   // Mark this block as having no special instructions.
   FirstSpecialInsts[BB] = nullptr;