[llvm] [Attributor] Report change when updating ReachesReturn (PR #108965)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 04:53:51 PDT 2024


https://github.com/macurtis-amd created https://github.com/llvm/llvm-project/pull/108965

None

>From 70159df2cfc53f352345dfdba911530843fbbf46 Mon Sep 17 00:00:00 2001
From: Matthew Curtis <macurtis at amd.com>
Date: Sat, 14 Sep 2024 07:57:24 -0500
Subject: [PATCH] [Attributor] Report change when updating ReachesReturn

Change-Id: I1b847cdaab3e4c4aced05d688c210b8484502873
---
 .../Transforms/IPO/AttributorAttributes.cpp    | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 217c7cccb5775a..8507cbcf5fb450 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1093,6 +1093,14 @@ struct AAPointerInfoImpl
     return State::numOffsetBins();
   }
   virtual bool reachesReturn() const override { return ReachesReturn; }
+  ChangeStatus setReachesReturn(bool val) {
+    if (ReachesReturn == val)
+      return ChangeStatus::UNCHANGED;
+
+    ReachesReturn = val;
+    return ChangeStatus::CHANGED;
+  }
+
 
   bool forallInterferingAccesses(
       AA::RangeTy Range,
@@ -1380,12 +1388,12 @@ struct AAPointerInfoImpl
     if (!OtherAA.getState().isValidState() || !isValidState())
       return indicatePessimisticFixpoint();
 
+    ChangeStatus Changed = ChangeStatus::UNCHANGED;
     const auto &OtherAAImpl = static_cast<const AAPointerInfoImpl &>(OtherAA);
     bool IsByval = OtherAAImpl.getAssociatedArgument()->hasByValAttr();
-    ReachesReturn = OtherAAImpl.ReachesReturn;
+    Changed |= setReachesReturn(OtherAAImpl.ReachesReturn);
 
     // Combine the accesses bin by bin.
-    ChangeStatus Changed = ChangeStatus::UNCHANGED;
     const auto &State = OtherAAImpl.getState();
     for (const auto &It : State) {
       for (auto Index : It.getSecond()) {
@@ -1681,8 +1689,10 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
     // Returns are allowed if they are in the associated functions. Users can
     // then check the call site return. Returns from other functions can't be
     // tracked and are cause for invalidation.
-    if (auto *RI = dyn_cast<ReturnInst>(Usr))
-      return ReachesReturn = RI->getFunction() == getAssociatedFunction();
+    if (auto *RI = dyn_cast<ReturnInst>(Usr)) {
+      Changed |= setReachesReturn(RI->getFunction() == getAssociatedFunction());
+      return ReachesReturn;
+    }
 
     // For PHIs we need to take care of the recurrence explicitly as the value
     // might change while we iterate through a loop. For now, we give up if



More information about the llvm-commits mailing list