[llvm] 54d01cb - [IPT] Don't use OrderedInstructions (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 20 09:27:26 PDT 2020


Author: Nikita Popov
Date: 2020-04-20T18:25:31+02:00
New Revision: 54d01cbc15eabb3daf4911d7bc935082846ac271

URL: https://github.com/llvm/llvm-project/commit/54d01cbc15eabb3daf4911d7bc935082846ac271
DIFF: https://github.com/llvm/llvm-project/commit/54d01cbc15eabb3daf4911d7bc935082846ac271.diff

LOG: [IPT] Don't use OrderedInstructions (NFC)

Use Instruction::comesBefore() instead of OrderedInstructions
inside InstructionPrecedenceTracking. This also removes the
dominator tree dependency.

Differential Revision: https://reviews.llvm.org/D78461

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/InstructionPrecedenceTracking.h
    llvm/include/llvm/Analysis/MustExecute.h
    llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
    llvm/lib/Transforms/Scalar/GVN.cpp
    llvm/lib/Transforms/Scalar/LICM.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/InstructionPrecedenceTracking.h b/llvm/include/llvm/Analysis/InstructionPrecedenceTracking.h
index 3c3981066a49..0391f2cdd913 100644
--- a/llvm/include/llvm/Analysis/InstructionPrecedenceTracking.h
+++ b/llvm/include/llvm/Analysis/InstructionPrecedenceTracking.h
@@ -20,18 +20,18 @@
 #ifndef LLVM_ANALYSIS_INSTRUCTIONPRECEDENCETRACKING_H
 #define LLVM_ANALYSIS_INSTRUCTIONPRECEDENCETRACKING_H
 
-#include "llvm/IR/Dominators.h"
-#include "llvm/Analysis/OrderedInstructions.h"
+#include "llvm/ADT/DenseMap.h"
 
 namespace llvm {
 
+class BasicBlock;
+class Instruction;
+
 class InstructionPrecedenceTracking {
   // Maps a block to the topmost special instruction in it. If the value is
   // nullptr, it means that it is known that this block does not contain any
   // special instructions.
   DenseMap<const BasicBlock *, const Instruction *> FirstSpecialInsts;
-  // Allows to answer queries about precedence of instructions within one block.
-  OrderedInstructions OI;
 
   // Fills information about the given block's special instructions.
   void fill(const BasicBlock *BB);
@@ -49,9 +49,6 @@ class InstructionPrecedenceTracking {
 #endif
 
 protected:
-  InstructionPrecedenceTracking(DominatorTree *DT)
-      : OI(OrderedInstructions(DT)) {}
-
   /// Returns the topmost special instruction from the block \p BB. Returns
   /// nullptr if there is no special instructions in the block.
   const Instruction *getFirstSpecialInstruction(const BasicBlock *BB);
@@ -96,9 +93,6 @@ class InstructionPrecedenceTracking {
 /// perform PRE moving non-speculable instruction to other place.
 class ImplicitControlFlowTracking : public InstructionPrecedenceTracking {
 public:
-  ImplicitControlFlowTracking(DominatorTree *DT)
-      : InstructionPrecedenceTracking(DT) {}
-
   /// Returns the topmost instruction with implicit control flow from the given
   /// basic block. Returns nullptr if there is no such instructions in the block.
   const Instruction *getFirstICFI(const BasicBlock *BB) {
@@ -121,8 +115,6 @@ class ImplicitControlFlowTracking : public InstructionPrecedenceTracking {
 
 class MemoryWriteTracking : public InstructionPrecedenceTracking {
 public:
-  MemoryWriteTracking(DominatorTree *DT) : InstructionPrecedenceTracking(DT) {}
-
   /// Returns the topmost instruction that may write memory from the given
   /// basic block. Returns nullptr if there is no such instructions in the block.
   const Instruction *getFirstMemoryWrite(const BasicBlock *BB) {

diff  --git a/llvm/include/llvm/Analysis/MustExecute.h b/llvm/include/llvm/Analysis/MustExecute.h
index f40fa1f8bf9d..16da0c0a4650 100644
--- a/llvm/include/llvm/Analysis/MustExecute.h
+++ b/llvm/include/llvm/Analysis/MustExecute.h
@@ -122,8 +122,6 @@ class SimpleLoopSafetyInfo: public LoopSafetyInfo {
                                      const DominatorTree *DT,
                                      const Loop *CurLoop) const;
 
-  SimpleLoopSafetyInfo() : LoopSafetyInfo() {};
-
   virtual ~SimpleLoopSafetyInfo() {};
 };
 
@@ -171,8 +169,6 @@ class ICFLoopSafetyInfo: public LoopSafetyInfo {
   /// this removal.
   void removeInstruction(const Instruction *Inst);
 
-  ICFLoopSafetyInfo(DominatorTree *DT) : LoopSafetyInfo(), ICF(DT), MW(DT) {};
-
   virtual ~ICFLoopSafetyInfo() {};
 };
 

diff  --git a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
index a6e4455c2e6e..c26cdf2266da 100644
--- a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
+++ b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
@@ -59,7 +59,7 @@ bool InstructionPrecedenceTracking::isPreceededBySpecialInstruction(
     const Instruction *Insn) {
   const Instruction *MaybeFirstSpecial =
       getFirstSpecialInstruction(Insn->getParent());
-  return MaybeFirstSpecial && OI.dominates(MaybeFirstSpecial, Insn);
+  return MaybeFirstSpecial && MaybeFirstSpecial->comesBefore(Insn);
 }
 
 void InstructionPrecedenceTracking::fill(const BasicBlock *BB) {

diff  --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 98070ec4ff97..af9118bc0a47 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2145,7 +2145,7 @@ bool GVN::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
   TLI = &RunTLI;
   VN.setAliasAnalysis(&RunAA);
   MD = RunMD;
-  ImplicitControlFlowTracking ImplicitCFT(DT);
+  ImplicitControlFlowTracking ImplicitCFT;
   ICF = &ImplicitCFT;
   this->LI = LI;
   VN.setMemDep(MD);

diff  --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 8df785aac7e1..ed9d70fb2e78 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -331,7 +331,7 @@ bool LoopInvariantCodeMotion::runOnLoop(
   BasicBlock *Preheader = L->getLoopPreheader();
 
   // Compute loop safety information.
-  ICFLoopSafetyInfo SafetyInfo(DT);
+  ICFLoopSafetyInfo SafetyInfo;
   SafetyInfo.computeLoopSafetyInfo(L);
 
   // We want to visit all of the instructions in this loop... that are not parts


        


More information about the llvm-commits mailing list