[llvm] b4498e6 - [IPT] Narrow scope of removeInstruction invalidation [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 8 10:35:09 PDT 2021


Author: Philip Reames
Date: 2021-10-08T10:35:03-07:00
New Revision: b4498e6b8d7f55e0fe9e26a5f5d21ec1a78f6fb0

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

LOG: [IPT] Narrow scope of removeInstruction invalidation [NFC]

We only need to invalidate if the instruction being removed is the cached "first special instruction".  If the instruction is before that one, it can't (by assumption) be special.  If it is after that one, it wasn't the first.

Added: 
    

Modified: 
    llvm/lib/Analysis/InstructionPrecedenceTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
index 7d1e630e6e80..e22655510666 100644
--- a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
+++ b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
@@ -107,8 +107,10 @@ void InstructionPrecedenceTracking::insertInstructionTo(const Instruction *Inst,
 }
 
 void InstructionPrecedenceTracking::removeInstruction(const Instruction *Inst) {
-  if (isSpecialInstruction(Inst))
-    FirstSpecialInsts.erase(Inst->getParent());
+  auto *BB = Inst->getParent();
+  assert(BB && "must be called before instruction is actually removed");
+  if (FirstSpecialInsts.count(BB) && FirstSpecialInsts[BB] == Inst)
+    FirstSpecialInsts.erase(BB);
 }
 
 void InstructionPrecedenceTracking::removeUsersOf(const Instruction *Inst) {


        


More information about the llvm-commits mailing list