]> granicus.if.org Git - llvm/commitdiff
[Attributor] Fix the "clamp" operator
authorJohannes Doerfert <jdoerfert@anl.gov>
Tue, 20 Aug 2019 05:57:01 +0000 (05:57 +0000)
committerJohannes Doerfert <jdoerfert@anl.gov>
Tue, 20 Aug 2019 05:57:01 +0000 (05:57 +0000)
The clamp operator should not take the known of the given state as the
known is potentially based on assumed information. This also adds TODOs
to guide improvements.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369327 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/IPO/Attributor.h
lib/Transforms/IPO/Attributor.cpp

index 484dd0c31e25f0803a97f4c0be66092a71461346..7e03e54fde5da08650e8719a4312234185b9e21c 100644 (file)
@@ -890,10 +890,13 @@ struct IntegerState : public AbstractState {
   /// Inequality for IntegerState.
   bool operator!=(const IntegerState &R) const { return !(*this == R); }
 
-  /// "Clamp" this state with \p R. The result is the maximum of the known
-  /// information but the minimum of the assumed.
+  /// "Clamp" this state with \p R. The result is the minimum of the assumed
+  /// information but not less than what was known before.
+  ///
+  /// TODO: Consider replacing the operator with a call or using it only when
+  ///       we can also take the maximum of the known information, thus when
+  ///       \p R is not dependent on additional assumed state.
   IntegerState operator^=(const IntegerState &R) {
-    takeKnownMaximum(R.Known);
     takeAssumedMinimum(R.Assumed);
     return *this;
   }
index 5ad9d4cb977a6db8bf1b9d8a833c9f4e4b8cde9f..ee3541b7c1db77f5849ef19cb716839c6574b333 100644 (file)
@@ -526,6 +526,8 @@ struct AAReturnedFromReturnedValues : public AAType {
   ChangeStatus updateImpl(Attributor &A) override {
     StateType S;
     clampReturnedValueStates<AAType, StateType>(A, *this, S);
+    // TODO: If we know we visited all returned values, thus no are assumed
+    // dead, we can take the known information from the state T.
     return clampStateAndIndicateChange<StateType>(this->getState(), S);
   }
 };
@@ -585,6 +587,8 @@ struct AAArgumentFromCallSiteArguments : public AAType {
   ChangeStatus updateImpl(Attributor &A) override {
     StateType S;
     clampCallSiteArgumentStates<AAType, StateType>(A, *this, S);
+    // TODO: If we know we visited all incoming values, thus no are assumed
+    // dead, we can take the known information from the state T.
     return clampStateAndIndicateChange<StateType>(this->getState(), S);
   }
 };
@@ -2265,6 +2269,8 @@ struct AAAlignFloating : AAAlignImpl {
                                                    VisitValueCB))
       indicatePessimisticFixpoint();
 
+    // TODO: If we know we visited all incoming values, thus no are assumed
+    // dead, we can take the known information from the state T.
     return clampStateAndIndicateChange(getState(), T);
   }