diff options
| author | Tim Renouf <tpr.llvm@botech.co.uk> | 2018-07-13 13:13:30 +0000 |
|---|---|---|
| committer | Tim Renouf <tpr.llvm@botech.co.uk> | 2018-07-13 13:13:30 +0000 |
| commit | f3d8295105017ce7e42cbf33d718dc602edefbef (patch) | |
| tree | eedc902ee9b12081bce7224d8b5b02a0a41134bc /llvm/lib/Analysis | |
| parent | e0e5b4cf2e8e2a878fb3d75c32bfda8905431de6 (diff) | |
| download | bcm5719-llvm-f3d8295105017ce7e42cbf33d718dc602edefbef.tar.gz bcm5719-llvm-f3d8295105017ce7e42cbf33d718dc602edefbef.zip | |
DivergenceAnalysis: added debug output
Summary:
This commit does two things:
1. modified the existing DivergenceAnalysis::dump() so it dumps the
whole function with added DIVERGENT: annotations;
2. added code to do that dump if the appropriate -debug-only option is
on.
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D47700
Change-Id: Id97b605aab1fc6f5a11a20c58a99bbe8c565bf83
llvm-svn: 336998
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/DivergenceAnalysis.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/DivergenceAnalysis.cpp b/llvm/lib/Analysis/DivergenceAnalysis.cpp index ac684ec1846..f5f1874c930 100644 --- a/llvm/lib/Analysis/DivergenceAnalysis.cpp +++ b/llvm/lib/Analysis/DivergenceAnalysis.cpp @@ -77,6 +77,8 @@ #include <vector> using namespace llvm; +#define DEBUG_TYPE "divergence" + namespace { class DivergencePropagator { @@ -299,6 +301,10 @@ bool DivergenceAnalysis::runOnFunction(Function &F) { PDT, DivergentValues); DP.populateWithSourcesOfDivergence(); DP.propagate(); + LLVM_DEBUG( + dbgs() << "\nAfter divergence analysis on " << F.getName() << ":\n"; + print(dbgs(), F.getParent()) + ); return false; } @@ -318,12 +324,17 @@ void DivergenceAnalysis::print(raw_ostream &OS, const Module *) const { // Dumps all divergent values in F, arguments and then instructions. for (auto &Arg : F->args()) { - if (DivergentValues.count(&Arg)) - OS << "DIVERGENT: " << Arg << "\n"; + OS << (DivergentValues.count(&Arg) ? "DIVERGENT: " : " "); + OS << Arg << "\n"; } // Iterate instructions using instructions() to ensure a deterministic order. - for (auto &I : instructions(F)) { - if (DivergentValues.count(&I)) - OS << "DIVERGENT:" << I << "\n"; + for (auto BI = F->begin(), BE = F->end(); BI != BE; ++BI) { + auto &BB = *BI; + OS << "\n " << BB.getName() << ":\n"; + for (auto &I : BB.instructionsWithoutDebug()) { + OS << (DivergentValues.count(&I) ? "DIVERGENT: " : " "); + OS << I << "\n"; + } } + OS << "\n"; } |

