[llvm] b96ea6b - [Attributor] Ensure to simplify operands in AAValueConstantRange

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 19 22:35:55 PDT 2021


Author: Johannes Doerfert
Date: 2021-07-20T00:35:14-05:00
New Revision: b96ea6b1fd260f09a246b9d168ea166bb7a199d1

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

LOG: [Attributor] Ensure to simplify operands in AAValueConstantRange

As with other patches before, the simplification callback interface
requires us to go through the Attributor::getAssumedSimplified API first
before we recurs.

It is unclear if the problem can be explicitly tested with our current
infrastructure.

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 f514c170747b..97537559629c 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -8279,9 +8279,20 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
       Instruction *I = dyn_cast<Instruction>(&V);
       if (!I || isa<CallBase>(I)) {
 
+        // Simplify the operand first.
+        bool UsedAssumedInformation = false;
+        const auto &SimplifiedOpV =
+            A.getAssumedSimplified(IRPosition::value(V, getCallBaseContext()),
+                                   *this, UsedAssumedInformation);
+        if (!SimplifiedOpV.hasValue())
+          return true;
+        Value *VPtr = &V;
+        if (*SimplifiedOpV)
+          VPtr = *SimplifiedOpV;
+
         // If the value is not instruction, we query AA to Attributor.
         const auto &AA = A.getAAFor<AAValueConstantRange>(
-            *this, IRPosition::value(V, getCallBaseContext()),
+            *this, IRPosition::value(*VPtr, getCallBaseContext()),
             DepClassTy::REQUIRED);
 
         // Clamp operator is not used to utilize a program point CtxI.


        


More information about the llvm-commits mailing list