diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-07-25 23:04:36 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-07-25 23:04:36 +0000 |
commit | bf115314923f31a7d4e2a4aca85b5734457a8d2a (patch) | |
tree | 2cdfd0bde4b74b2d4e8398829b0723072ac06235 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 1740a977347613298b76b929329db9bc8c3de707 (diff) | |
download | bcm5719-llvm-bf115314923f31a7d4e2a4aca85b5734457a8d2a.tar.gz bcm5719-llvm-bf115314923f31a7d4e2a4aca85b5734457a8d2a.zip |
llvm-objdump: Ignore unreachable blocks when printing the CFG.
llvm-svn: 136000
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index f4c1ccdf7c1..99549266c24 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" +#include "llvm/Support/GraphWriter.h" #include "llvm/Support/Host.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" @@ -280,12 +281,28 @@ static void DisassembleInput(const StringRef &Filename) { Out << "digraph " << f.getName() << " {\n"; Out << "graph [ rankdir = \"LR\" ];\n"; for (MCFunction::iterator i = f.begin(), e = f.end(); i != e; ++i) { + bool hasPreds = false; + // Only print blocks that have predecessors. + // FIXME: Slow. + for (MCFunction::iterator pi = f.begin(), pe = f.end(); pi != pe; + ++pi) + for (pi->second->contains(&i->second)) { + hasPreds = true; + break; + } + + if (!hasPreds && i != f.begin()) + continue; + Out << '"' << (uintptr_t)&i->second << "\" [ label=\"<a>"; // Print instructions. for (unsigned ii = 0, ie = i->second.getInsts().size(); ii != ie; ++ii) { - IP->printInst(&i->second.getInsts()[ii].Inst, Out); - Out << '|'; + // Escape special chars and print the instruction in mnemonic form. + std::string Str; + raw_string_ostream OS(Str); + IP->printInst(&i->second.getInsts()[ii].Inst, OS); + Out << DOT::EscapeString(OS.str()) << '|'; } Out << "<o>\" shape=\"record\" ];\n"; |