From f2f00fb11ac2d2708f727f11269c20a3cba75fe5 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Sun, 1 May 2016 04:51:05 +0000 Subject: [SCEV] When printing via -analysis, dump loop disposition There are currently some bugs in tree around SCEV caching an incorrect loop disposition. Printing out loop dispositions will let us write whitebox tests as those are fixed. The dispositions are printed as a list in "inside out" order, i.e. innermost loop first. llvm-svn: 268177 --- llvm/lib/Analysis/ScalarEvolution.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp') diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index cfb9f5e2..99c6500 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -9565,6 +9565,17 @@ static void PrintLoopInfo(raw_ostream &OS, ScalarEvolution *SE, OS << "\n"; } +static StringRef loopDispositionToStr(ScalarEvolution::LoopDisposition LD) { + switch (LD) { + case ScalarEvolution::LoopVariant: + return "Variant"; + case ScalarEvolution::LoopInvariant: + return "Invariant"; + case ScalarEvolution::LoopComputable: + return "Computable"; + } +} + void ScalarEvolution::print(raw_ostream &OS) const { // ScalarEvolution's implementation of the print method is to print // out SCEV values of all instructions that are interesting. Doing @@ -9612,6 +9623,20 @@ void ScalarEvolution::print(raw_ostream &OS) const { } else { OS << *ExitValue; } + + bool First = true; + for (auto *Iter = L; Iter; Iter = Iter->getParentLoop()) { + if (First) { + OS << "\t\t" "LoopDispositions: [ "; + First = false; + } else { + OS << ", "; + } + + OS << loopDispositionToStr(SE.getLoopDisposition(SV, Iter)); + } + + OS << " ]"; } OS << "\n"; -- cgit v1.1