[llvm] 8133778 - [SCEV] Fully invalidate SCEVUnknown on RAUW

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 00:39:57 PST 2022


Author: Nikita Popov
Date: 2022-03-07T09:28:28+01:00
New Revision: 8133778d3c8d481891143e21e0c5081a02a9889d

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

LOG: [SCEV] Fully invalidate SCEVUnknown on RAUW

When a SCEVUnknown gets RAUWd, we currently drop it from the folding
set, but don't forget memoized values. I believe we should be
treating RAUW the same way as deletion here and invalidate all
caches and dependent expressions.

I don't have any specific cases where this causes issues right now,
but it does address the FIXME in https://reviews.llvm.org/D119488.

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

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index e66e9ec52124c..7d2d3381230ba 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -526,12 +526,13 @@ void SCEVUnknown::deleted() {
 }
 
 void SCEVUnknown::allUsesReplacedWith(Value *New) {
+  // Clear this SCEVUnknown from various maps.
+  SE->forgetMemoizedResults(this);
+
   // Remove this SCEVUnknown from the uniquing map.
   SE->UniqueSCEVs.RemoveNode(this);
 
-  // Update this SCEVUnknown to point to the new value. This is needed
-  // because there may still be outstanding SCEVs which still point to
-  // this SCEVUnknown.
+  // Replace the value pointer in case someone is still using this SCEVUnknown.
   setValPtr(New);
 }
 


        


More information about the llvm-commits mailing list