From ac96c8fd8535b50ab5ac158f521b0be8800df6fd Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 23 Mar 2020 01:11:39 -0500 Subject: [PATCH] [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. --- llvm/lib/Transforms/IPO/Attributor.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 0de59b388ef27..b712ef75d26fe 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 {