[PATCH] D120033: [SCEV] Fully invalidate SCEVUnknown on RAUW

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 17 03:10:35 PST 2022


nikic created this revision.
nikic added reviewers: reames, lebedev.ri, mkazantsev.
Herald added subscribers: javed.absar, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When a SCEVUnknown gets RAUWd, we currently drop it from the value map, but we 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. This patch is inspired by the FIXME in https://reviews.llvm.org/D119488.


https://reviews.llvm.org/D120033

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp


Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -519,13 +519,9 @@
 }
 
 void SCEVUnknown::allUsesReplacedWith(Value *New) {
-  // 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.
-  setValPtr(New);
+  // Treat this the same way as the value being deleted, to force
+  // recomputation of dependent expressions.
+  deleted();
 }
 
 bool SCEVUnknown::isSizeOf(Type *&AllocTy) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120033.409568.patch
Type: text/x-patch
Size: 739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220217/045c8f28/attachment.bin>


More information about the llvm-commits mailing list