[PATCH] D52017: [NFC] Introduce surgical invalidation of IPT

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 13 22:34:05 PDT 2018


mkazantsev updated this revision to Diff 165426.
mkazantsev added a reviewer: fhahn.
mkazantsev added a comment.

Fixed formatting.


https://reviews.llvm.org/D52017

Files:
  include/llvm/Analysis/InstructionPrecedenceTracking.h
  lib/Analysis/InstructionPrecedenceTracking.cpp


Index: lib/Analysis/InstructionPrecedenceTracking.cpp
===================================================================
--- lib/Analysis/InstructionPrecedenceTracking.cpp
+++ lib/Analysis/InstructionPrecedenceTracking.cpp
@@ -103,6 +103,20 @@
   FirstSpecialInsts.erase(BB);
 }
 
+void
+InstructionPrecedenceTracking::invalidateInstruction(const Instruction *Insn) {
+  // If we keep track of Insn, drop the cached info for it.
+  if (!isSpecialInstruction(Insn))
+    return;
+
+  auto It = FirstSpecialInsts.find(Insn->getParent());
+  if (It == FirstSpecialInsts.end())
+    return;
+
+  if (It->second == Insn)
+    FirstSpecialInsts.erase(It);
+}
+
 void InstructionPrecedenceTracking::clear() {
   FirstSpecialInsts.clear();
 #ifndef NDEBUG
Index: include/llvm/Analysis/InstructionPrecedenceTracking.h
===================================================================
--- include/llvm/Analysis/InstructionPrecedenceTracking.h
+++ include/llvm/Analysis/InstructionPrecedenceTracking.h
@@ -75,9 +75,15 @@
   virtual ~InstructionPrecedenceTracking() = default;
 
 public:
-  /// Clears cached information about this particular block.
+  /// Clears cached information about this particular block. We need to do it
+  /// whenever we plan to modify blocks contents in a way that may change the
+  /// first special instruction in the block.
   void invalidateBlock(const BasicBlock *BB);
 
+  /// Inform the tracking that we are going to remove or modify the instuction
+  /// \p Insn. It will do the required invalidation if needed.
+  void invalidateInstruction(const Instruction *Insn);
+
   /// Invalidates all information from this tracking.
   void clear();
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52017.165426.patch
Type: text/x-patch
Size: 1673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180914/b9859c9f/attachment.bin>


More information about the llvm-commits mailing list