From b504eb8bb5ed952533a4fbb113e5a63ba6fd859d Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 26 Aug 2019 18:55:47 +0000 Subject: [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 --- llvm/lib/Transforms/IPO/Attributor.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index ebe4fba0856..a6e8e528fd0 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -107,6 +107,10 @@ static cl::opt MaxFixpointIterations("attributor-max-iterations", cl::Hidden, cl::desc("Maximal number of fixpoint iterations."), cl::init(32)); +static cl::opt 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 DisableAttributor( "attributor-disable", cl::Hidden, @@ -2509,6 +2513,10 @@ ChangeStatus Attributor::run() { Worklist.insert(QuerriedAAs.begin(), QuerriedAAs.end()); } + LLVM_DEBUG(dbgs() << "[Attributor] #Iteration: " << IterationCounter + << ", Worklist+Dependent size: " << Worklist.size() + << "\n"); + // Reset the changed set. ChangedAAs.clear(); @@ -2529,7 +2537,7 @@ ChangeStatus Attributor::run() { Worklist.clear(); Worklist.insert(ChangedAAs.begin(), ChangedAAs.end()); - } while (!Worklist.empty() && ++IterationCounter < MaxFixpointIterations); + } while (!Worklist.empty() && IterationCounter++ < MaxFixpointIterations); size_t NumFinalAAs = AllAbstractAttributes.size(); @@ -2537,6 +2545,10 @@ ChangeStatus Attributor::run() { << IterationCounter << "/" << MaxFixpointIterations << " iterations\n"); + if (VerifyMaxFixpointIterations && IterationCounter != MaxFixpointIterations) + llvm_unreachable("The fixpoint was not reached with exactly the number of " + "specified iterations!"); + bool FinishedAtFixpoint = Worklist.empty(); // Reset abstract arguments not settled in a sound fixpoint by now. This -- cgit v1.2.3