[llvm] e6f3e64 - [Attributor][FIX] Do not return CHANGED unconditionally

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 19:26:34 PDT 2021


Author: Johannes Doerfert
Date: 2021-07-26T21:22:02-05:00
New Revision: e6f3e648c9caf84fca9d2039138b5b539b398f70

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

LOG: [Attributor][FIX] Do not return CHANGED unconditionally

This caused us to rerun AAMemoryBehaviorFloating::updateImpl over and
over again. Unfortunately it turned out to be hard to reproduce the
behavior in a reasonable way.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 309c692d454d..170377fdc482 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7097,6 +7097,9 @@ ChangeStatus AAMemoryBehaviorFloating::updateImpl(Attributor &A) {
       return ChangeStatus::UNCHANGED;
   }
 
+  // The current assumed state used to determine a change.
+  auto AssumedState = S.getAssumed();
+
   // Make sure the value is not captured (except through "return"), if
   // it is, any information derived would be irrelevant anyway as we cannot
   // check the potential aliases introduced by the capture. However, no need
@@ -7105,12 +7108,10 @@ ChangeStatus AAMemoryBehaviorFloating::updateImpl(Attributor &A) {
       A.getAAFor<AANoCapture>(*this, IRP, DepClassTy::OPTIONAL);
   if (!ArgNoCaptureAA.isAssumedNoCaptureMaybeReturned()) {
     S.intersectAssumedBits(FnMemAssumedState);
-    return ChangeStatus::CHANGED;
+    return (AssumedState != getAssumed()) ? ChangeStatus::CHANGED
+                                          : ChangeStatus::UNCHANGED;
   }
 
-  // The current assumed state used to determine a change.
-  auto AssumedState = S.getAssumed();
-
   // Visit and expand uses until all are analyzed or a fixpoint is reached.
   auto UsePred = [&](const Use &U, bool &Follow) -> bool {
     Instruction *UserI = cast<Instruction>(U.getUser());


        


More information about the llvm-commits mailing list