[llvm] r345822 - [NFC] Specialize public API of ICFLoopSafetyInfo for insertions and removals

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 1 03:16:06 PDT 2018


Author: mkazantsev
Date: Thu Nov  1 03:16:06 2018
New Revision: 345822

URL: http://llvm.org/viewvc/llvm-project?rev=345822&view=rev
Log:
[NFC] Specialize public API of ICFLoopSafetyInfo for insertions and removals

Modified:
    llvm/trunk/include/llvm/Analysis/MustExecute.h
    llvm/trunk/lib/Analysis/MustExecute.cpp

Modified: llvm/trunk/include/llvm/Analysis/MustExecute.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MustExecute.h?rev=345822&r1=345821&r2=345822&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/MustExecute.h (original)
+++ llvm/trunk/include/llvm/Analysis/MustExecute.h Thu Nov  1 03:16:06 2018
@@ -125,8 +125,9 @@ public:
 
 /// This implementation of LoopSafetyInfo use ImplicitControlFlowTracking to
 /// give precise answers on "may throw" queries. This implementation uses cache
-/// that should be invalidated by calling the method dropCachedInfo whenever we
-/// modify a basic block's contents by adding or removing instructions.
+/// that should be invalidated by calling the methods insertInstructionTo and
+/// removeInstruction whenever we modify a basic block's contents by adding or
+/// removing instructions.
 class ICFLoopSafetyInfo: public LoopSafetyInfo {
   bool MayThrow = false;       // The current loop contains an instruction which
                                // may throw.
@@ -144,10 +145,15 @@ public:
                                      const DominatorTree *DT,
                                      const Loop *CurLoop) const;
 
-  /// Drops cached information regarding the implicit control flow in block
-  /// \p BB. It should be called for every block in which we add or remove any
-  /// instructions  to a block before we make queries to it.
-  void dropCachedInfo(const BasicBlock *BB);
+  /// Inform the safety info that we are planning to insert a new instruction
+  /// into the basic block \p BB. It will make all cache updates to keep it
+  /// correct after this insertion.
+  void insertInstructionTo(const BasicBlock *BB);
+
+  /// Inform safety info that we are planning to remove the instruction \p Inst
+  /// from its block. It will make all cache updates to keep it correct after
+  /// this removal.
+  void removeInstruction(const Instruction *Inst);
 
   ICFLoopSafetyInfo(DominatorTree *DT) : LoopSafetyInfo(), ICF(DT) {};
 

Modified: llvm/trunk/lib/Analysis/MustExecute.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MustExecute.cpp?rev=345822&r1=345821&r2=345822&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MustExecute.cpp (original)
+++ llvm/trunk/lib/Analysis/MustExecute.cpp Thu Nov  1 03:16:06 2018
@@ -82,10 +82,16 @@ void ICFLoopSafetyInfo::computeLoopSafet
   computeBlockColors(CurLoop);
 }
 
-void ICFLoopSafetyInfo::dropCachedInfo(const BasicBlock *BB) {
+void ICFLoopSafetyInfo::insertInstructionTo(const BasicBlock *BB) {
   ICF.invalidateBlock(BB);
 }
 
+void ICFLoopSafetyInfo::removeInstruction(const Instruction *Inst) {
+  // TODO: So far we just conservatively drop cache, but maybe we can not do it
+  // when Inst is not an ICF instruction. Follow-up on that.
+  ICF.invalidateBlock(Inst->getParent());
+}
+
 void LoopSafetyInfo::computeBlockColors(const Loop *CurLoop) {
   // Compute funclet colors if we might sink/hoist in a function with a funclet
   // personality routine.




More information about the llvm-commits mailing list