From 71bd86378b1ede300e904acc848c50cb40321659 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 17 Mar 2015 01:40:22 +0000 Subject: [PATCH] [IRCE] Add a -irce-print-range-checks option. -irce-print-range-checks prints out the set of range checks recognized by IRCE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232451 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Scalar/InductiveRangeCheckElimination.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp index 22ce7119cb7..dd0c9fd80d1 100644 --- a/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ b/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -82,6 +82,9 @@ static cl::opt LoopSizeCutoff("irce-loop-size-cutoff", cl::Hidden, static cl::opt PrintChangedLoops("irce-print-changed-loops", cl::Hidden, cl::init(false)); +static cl::opt PrintRangeChecks("irce-print-range-checks", cl::Hidden, + cl::init(false)); + static cl::opt MaxExitProbReciprocal("irce-max-exit-prob-reciprocal", cl::Hidden, cl::init(10)); @@ -1392,12 +1395,18 @@ bool InductiveRangeCheckElimination::runOnLoop(Loop *L, LPPassManager &LPM) { if (RangeChecks.empty()) return false; - DEBUG(dbgs() << "irce: looking at loop "; L->print(dbgs()); - dbgs() << "irce: loop has " << RangeChecks.size() - << " inductive range checks: \n"; - for (InductiveRangeCheck *IRC : RangeChecks) - IRC->print(dbgs()); - ); + auto PrintRecognizedRangeChecks = [&](raw_ostream &OS) { + OS << "irce: looking at loop "; L->print(OS); + OS << "irce: loop has " << RangeChecks.size() + << " inductive range checks: \n"; + for (InductiveRangeCheck *IRC : RangeChecks) + IRC->print(OS); + }; + + DEBUG(PrintRecognizedRangeChecks(dbgs())); + + if (PrintRangeChecks) + PrintRecognizedRangeChecks(errs()); const char *FailureReason = nullptr; Optional MaybeLoopStructure = -- 2.34.1