[llvm-commits] [llvm] r136000 - in /llvm/trunk/tools/llvm-objdump: MCFunction.cpp llvm-objdump.cpp
Benjamin Kramer
benny.kra at googlemail.com
Mon Jul 25 16:04:36 PDT 2011
Author: d0k
Date: Mon Jul 25 18:04:36 2011
New Revision: 136000
URL: http://llvm.org/viewvc/llvm-project?rev=136000&view=rev
Log:
llvm-objdump: Ignore unreachable blocks when printing the CFG.
Modified:
llvm/trunk/tools/llvm-objdump/MCFunction.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/tools/llvm-objdump/MCFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MCFunction.cpp?rev=136000&r1=135999&r2=136000&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MCFunction.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MCFunction.cpp Mon Jul 25 18:04:36 2011
@@ -54,6 +54,8 @@
}
}
Splits.insert(Index+Size);
+ } else if (Desc.isReturn()) {
+ Splits.insert(Index+Size);
}
Instructions.push_back(MCDecodedInst(Index, Size, Inst));
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=136000&r1=135999&r2=136000&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Mon Jul 25 18:04:36 2011
@@ -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 @@
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";
More information about the llvm-commits
mailing list