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

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 04:54:22 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: None (macurtis-amd)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/108965.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+14-4) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/108965


More information about the llvm-commits mailing list