[Attributor] Adjust and test the iteration bound of tests

Summary:
Try to verify how many iterations we need for a fixpoint in our tests.
This patch adjust the way we count to make it easier to follow. It also
adjusts the bounds to actually account for a fixpoint and not only the
minimum number to pass all checks.

Reviewers: uenoku, sstefan1

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66757

llvm-svn: 369945
This commit is contained in:
Johannes Doerfert 2019-08-26 18:55:47 +00:00
parent 4d3a336612
commit b504eb8bb5
16 changed files with 28 additions and 16 deletions

View File

@ -107,6 +107,10 @@ static cl::opt<unsigned>
MaxFixpointIterations("attributor-max-iterations", cl::Hidden, MaxFixpointIterations("attributor-max-iterations", cl::Hidden,
cl::desc("Maximal number of fixpoint iterations."), cl::desc("Maximal number of fixpoint iterations."),
cl::init(32)); cl::init(32));
static cl::opt<bool> VerifyMaxFixpointIterations(
"attributor-max-iterations-verify", cl::Hidden,
cl::desc("Verify that max-iterations is a tight bound for a fixpoint"),
cl::init(false));
static cl::opt<bool> DisableAttributor( static cl::opt<bool> DisableAttributor(
"attributor-disable", cl::Hidden, "attributor-disable", cl::Hidden,
@ -2509,6 +2513,10 @@ ChangeStatus Attributor::run() {
Worklist.insert(QuerriedAAs.begin(), QuerriedAAs.end()); Worklist.insert(QuerriedAAs.begin(), QuerriedAAs.end());
} }
LLVM_DEBUG(dbgs() << "[Attributor] #Iteration: " << IterationCounter
<< ", Worklist+Dependent size: " << Worklist.size()
<< "\n");
// Reset the changed set. // Reset the changed set.
ChangedAAs.clear(); ChangedAAs.clear();
@ -2529,7 +2537,7 @@ ChangeStatus Attributor::run() {
Worklist.clear(); Worklist.clear();
Worklist.insert(ChangedAAs.begin(), ChangedAAs.end()); Worklist.insert(ChangedAAs.begin(), ChangedAAs.end());
} while (!Worklist.empty() && ++IterationCounter < MaxFixpointIterations); } while (!Worklist.empty() && IterationCounter++ < MaxFixpointIterations);
size_t NumFinalAAs = AllAbstractAttributes.size(); size_t NumFinalAAs = AllAbstractAttributes.size();
@ -2537,6 +2545,10 @@ ChangeStatus Attributor::run() {
<< IterationCounter << "/" << MaxFixpointIterations << IterationCounter << "/" << MaxFixpointIterations
<< " iterations\n"); << " iterations\n");
if (VerifyMaxFixpointIterations && IterationCounter != MaxFixpointIterations)
llvm_unreachable("The fixpoint was not reached with exactly the number of "
"specified iterations!");
bool FinishedAtFixpoint = Worklist.empty(); bool FinishedAtFixpoint = Worklist.empty();
// Reset abstract arguments not settled in a sound fixpoint by now. This // Reset abstract arguments not settled in a sound fixpoint by now. This

View File

@ -1,4 +1,4 @@
; RUN: opt -attributor -attributor-disable=false -attributor-max-iterations=32 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR ; RUN: opt -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=17 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -1,4 +1,4 @@
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations=19 -S < %s | FileCheck %s ; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=18 -S < %s | FileCheck %s
; ;
; Test cases specifically designed for the "no-capture" argument attribute. ; Test cases specifically designed for the "no-capture" argument attribute.
; We use FIXME's to indicate problems and missing attributes. ; We use FIXME's to indicate problems and missing attributes.

View File

@ -1,5 +1,5 @@
; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefix=FNATTR ; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefix=FNATTR
; RUN: opt -attributor -attributor-disable=false -attributor-max-iterations=27 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR ; RUN: opt -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=26 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR
; RUN: opt -attributor -attributor-disable=false -functionattrs -S < %s | FileCheck %s --check-prefix=BOTH ; RUN: opt -attributor -attributor-disable=false -functionattrs -S < %s | FileCheck %s --check-prefix=BOTH
; ;
; Test cases specifically designed for the "returned" argument attribute. ; Test cases specifically designed for the "returned" argument attribute.

View File

@ -1,4 +1,4 @@
; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR ; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=5 -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR
declare void @deref_phi_user(i32* %a); declare void @deref_phi_user(i32* %a);

View File

@ -1,4 +1,4 @@
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations=3 -S < %s | FileCheck %s ; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=4 -S < %s | FileCheck %s
; ;
; Test cases specifically designed for the "no-return" function attribute. ; Test cases specifically designed for the "no-return" function attribute.
; We use FIXME's to indicate problems and missing attributes. ; We use FIXME's to indicate problems and missing attributes.

View File

@ -1,4 +1,4 @@
; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations=6 -S < %s | FileCheck %s ; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=6 -S < %s | FileCheck %s
declare void @no_return_call() nofree noreturn nounwind readnone declare void @no_return_call() nofree noreturn nounwind readnone

View File

@ -1,4 +1,4 @@
; RUN: opt -S -attributor -attributor-disable=false -attributor-max-iterations=8 < %s | FileCheck %s ; RUN: opt -S -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=8 < %s | FileCheck %s
; TEST 1 - negative. ; TEST 1 - negative.

View File

@ -1,5 +1,5 @@
; RUN: opt -functionattrs --disable-nofree-inference=false -S < %s | FileCheck %s --check-prefix=FNATTR ; RUN: opt -functionattrs --disable-nofree-inference=false -S < %s | FileCheck %s --check-prefix=FNATTR
; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR ; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=8 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -1,6 +1,6 @@
; RUN: opt -S -functionattrs -enable-nonnull-arg-prop %s | FileCheck %s --check-prefixes=BOTH,FNATTR ; RUN: opt -S -functionattrs -enable-nonnull-arg-prop %s | FileCheck %s --check-prefixes=BOTH,FNATTR
; RUN: opt -S -passes=function-attrs -enable-nonnull-arg-prop %s | FileCheck %s --check-prefixes=BOTH,FNATTR ; RUN: opt -S -passes=function-attrs -enable-nonnull-arg-prop %s | FileCheck %s --check-prefixes=BOTH,FNATTR
; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations=32 -S < %s | FileCheck %s --check-prefixes=BOTH,ATTRIBUTOR ; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=12 -S < %s | FileCheck %s --check-prefixes=BOTH,ATTRIBUTOR
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -1,4 +1,4 @@
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations=5 -S < %s | FileCheck %s ; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=4 -S < %s | FileCheck %s
; ;
; This file is the same as noreturn_sync.ll but with a personality which ; This file is the same as noreturn_sync.ll but with a personality which
; indicates that the exception handler *can* catch asynchronous exceptions. As ; indicates that the exception handler *can* catch asynchronous exceptions. As

View File

@ -1,4 +1,4 @@
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations=32 -S < %s | FileCheck %s ; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=7 -S < %s | FileCheck %s
; ;
; This file is the same as noreturn_async.ll but with a personality which ; This file is the same as noreturn_async.ll but with a personality which
; indicates that the exception handler *cannot* catch asynchronous exceptions. ; indicates that the exception handler *cannot* catch asynchronous exceptions.

View File

@ -1,5 +1,5 @@
; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefix=FNATTR ; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefix=FNATTR
; RUN: opt -attributor -attributor-disable=false -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR ; RUN: opt -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
; Test cases designed for the nosync function attribute. ; Test cases designed for the nosync function attribute.

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -functionattrs -S | FileCheck %s ; RUN: opt < %s -functionattrs -S | FileCheck %s
; RUN: opt < %s -attributor -attributor-disable=false -attributor-max-iterations=9 -S | FileCheck %s --check-prefix=ATTRIBUTOR ; RUN: opt < %s -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=12 -S | FileCheck %s --check-prefix=ATTRIBUTOR
; TEST 1 ; TEST 1
; CHECK: Function Attrs: norecurse nounwind readnone ; CHECK: Function Attrs: norecurse nounwind readnone

View File

@ -1,4 +1,4 @@
; RUN: opt -functionattrs -enable-nonnull-arg-prop -attributor -attributor-disable=false -attributor-max-iterations=33 -S < %s | FileCheck %s ; RUN: opt -functionattrs -enable-nonnull-arg-prop -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=28 -S < %s | FileCheck %s
; ;
; This is an evolved example to stress test SCC parameter attribute propagation. ; This is an evolved example to stress test SCC parameter attribute propagation.
; The SCC in this test is made up of the following six function, three of which ; The SCC in this test is made up of the following six function, three of which

View File

@ -1,5 +1,5 @@
; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefix=FNATTR ; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefix=FNATTR
; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations=6 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR ; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=6 -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"