diff options
author | Fedor Sergeev <fedor.sergeev@oracle.com> | 2017-11-22 20:59:53 +0000 |
---|---|---|
committer | Fedor Sergeev <fedor.sergeev@oracle.com> | 2017-11-22 20:59:53 +0000 |
commit | a51f09141c70e6a5d98da3a993bde0631acc299e (patch) | |
tree | 1d67daf267b882bb9e46aac63be7828365e57ea9 /lib/Analysis | |
parent | 67b504e6c000ed2998620aa1fa4b63f4c458e9f0 (diff) |
IR printing improvement for loop passes
Summary:
Loop-pass printing is somewhat deficient since it does not provide the
context around the loop (e.g. preheader). This context information becomes
pretty essential when analyzing transformations that move stuff out of the loop.
Extending printLoop to cover preheader and exit blocks (if any).
Reviewers: sanjoy, silvas, weimingz
Reviewed By: sanjoy
Subscribers: apilipenko, skatkov, llvm-commits
Differential Revision: https://reviews.llvm.org/D40246
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318878 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index c6019f267a3..9a223df9394 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -732,11 +732,30 @@ PreservedAnalyses LoopPrinterPass::run(Function &F, void llvm::printLoop(Loop &L, raw_ostream &OS, const std::string &Banner) { OS << Banner; + + auto *PreHeader = L.getLoopPreheader(); + if (PreHeader) { + OS << "\n; Preheader:"; + PreHeader->print(OS); + OS << "\n; Loop:"; + } + for (auto *Block : L.blocks()) if (Block) Block->print(OS); else OS << "Printing <null> block"; + + SmallVector<BasicBlock *, 8> ExitBlocks; + L.getExitBlocks(ExitBlocks); + if (!ExitBlocks.empty()) { + OS << "\n; Exit blocks"; + for (auto *Block : ExitBlocks) + if (Block) + Block->print(OS); + else + OS << "Printing <null> block"; + } } //===----------------------------------------------------------------------===// |