[PATCH] D53786: [AliasSetTracker] Actually delete instructions from the AliasSetTracker.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 26 17:21:58 PDT 2018


asbirlea created this revision.
asbirlea added a reviewer: reames.
Herald added subscribers: jlebar, sanjoy.

When instructions are added, it's not the instruction being added, but its pointer.
The only actual instructions that are added are the unknown ones.
Trying to make some sense of this by actually removing pointers when an instruction is removed.
Oddly, this patch doesn't break anything.

Sending the changes to perhaps makes some sense on the purpose of the removeValue() function.
These changes are incomplete, given the special handling of arguments for callsites when adding an instruction,
but it's deleting more than before...


Repository:
  rL LLVM

https://reviews.llvm.org/D53786

Files:
  include/llvm/Analysis/AliasSetTracker.h
  lib/Analysis/AliasSetTracker.cpp
  lib/Transforms/Scalar/LICM.cpp


Index: lib/Transforms/Scalar/LICM.cpp
===================================================================
--- lib/Transforms/Scalar/LICM.cpp
+++ lib/Transforms/Scalar/LICM.cpp
@@ -315,7 +315,9 @@
       bool Promoted = false;
 
       // Loop over all of the alias sets in the tracker object.
-      for (AliasSet &AS : *CurAST) {
+      for (auto ASItB = CurAST->begin(), ASItE = CurAST->end(); ASItB != ASItE ; ) {
+        auto &AS = *ASItB;
+        ++ASItB;
         // We can promote this alias set if it has a store, if it is a "Must"
         // alias set, if the pointer is loop invariant, and if we are not
         // eliminating any volatile loads or stores.
Index: lib/Analysis/AliasSetTracker.cpp
===================================================================
--- lib/Analysis/AliasSetTracker.cpp
+++ lib/Analysis/AliasSetTracker.cpp
@@ -551,6 +551,14 @@
   PointerMap.erase(I);
 }
 
+void AliasSetTracker::deleteValue(Instruction *I) {
+  auto Loc = MemoryLocation::getOrNone(I);
+  if (Loc == None)
+    deleteValue((Value*) I);
+  else
+    deleteValue(const_cast<Value*>(Loc->Ptr));
+}
+
 // copyValue - This method should be used whenever a preexisting value in the
 // program is copied or cloned, introducing a new value.  Note that it is ok for
 // clients that use this method to introduce the same value multiple times: if
Index: include/llvm/Analysis/AliasSetTracker.h
===================================================================
--- include/llvm/Analysis/AliasSetTracker.h
+++ include/llvm/Analysis/AliasSetTracker.h
@@ -401,6 +401,7 @@
   /// program to update the AST. If you don't use this, you would have dangling
   /// pointers to deleted instructions.
   void deleteValue(Value *PtrVal);
+  void deleteValue(Instruction *I);
 
   /// This method should be used whenever a preexisting value in the program is
   /// copied or cloned, introducing a new value.  Note that it is ok for clients


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53786.171378.patch
Type: text/x-patch
Size: 1935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181027/5de4f758/attachment.bin>


More information about the llvm-commits mailing list