[llvm] ac96c8f - [Attributor][FIX] Do not compute ranges for arguments of declarations

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 20:21:56 PDT 2020


Author: Johannes Doerfert
Date: 2020-04-01T22:05:30-05:00
New Revision: ac96c8fd8535b50ab5ac158f521b0be8800df6fd

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

LOG: [Attributor][FIX] Do not compute ranges for arguments of declarations

This cannot be triggered right now, as far as I know, but it doesn't
make sense to deduce a constant range on arguments of declarations.
Exposed during testing of AAValueSimplify extensions.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 0de59b388ef2..b712ef75d26f 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -7052,10 +7052,18 @@ struct AAValueConstantRangeImpl : AAValueConstantRange {
 struct AAValueConstantRangeArgument final
     : AAArgumentFromCallSiteArguments<
           AAValueConstantRange, AAValueConstantRangeImpl, IntegerRangeState> {
-  AAValueConstantRangeArgument(const IRPosition &IRP)
-      : AAArgumentFromCallSiteArguments<
-            AAValueConstantRange, AAValueConstantRangeImpl, IntegerRangeState>(
-            IRP) {}
+  using Base = AAArgumentFromCallSiteArguments<
+      AAValueConstantRange, AAValueConstantRangeImpl, IntegerRangeState>;
+  AAValueConstantRangeArgument(const IRPosition &IRP) : Base(IRP) {}
+
+  /// See AbstractAttribute::initialize(..).
+  void initialize(Attributor &A) override {
+    if (!getAnchorScope() || getAnchorScope()->isDeclaration()) {
+      indicatePessimisticFixpoint();
+    } else {
+      Base::initialize(A);
+    }
+  }
 
   /// See AbstractAttribute::trackStatistics()
   void trackStatistics() const override {


        


More information about the llvm-commits mailing list