Add a statistic to track number of times we rebuild instruction ordering
authorPhilip Reames <listmail@philipreames.com>
Fri, 8 Oct 2021 17:45:01 +0000 (10:45 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 8 Oct 2021 17:59:34 +0000 (10:59 -0700)
The goal here is to assist some future tuning work both on instruction ordering invalidation, and on some client code which uses it.

llvm/lib/IR/BasicBlock.cpp

index d14abaf..ed1956e 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "llvm/IR/BasicBlock.h"
 #include "SymbolTableListTraitsImpl.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constants.h"
@@ -23,6 +24,9 @@
 
 using namespace llvm;
 
+#define DEBUG_TYPE "ir"
+STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks");
+
 ValueSymbolTable *BasicBlock::getValueSymbolTable() {
   if (Function *F = getParent())
     return F->getValueSymbolTable();
@@ -505,6 +509,8 @@ void BasicBlock::renumberInstructions() {
   BasicBlockBits Bits = getBasicBlockBits();
   Bits.InstrOrderValid = true;
   setBasicBlockBits(Bits);
+
+  NumInstrRenumberings++;
 }
 
 #ifndef NDEBUG