mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
llvm-objdump: Ignore unreachable blocks when printing the CFG.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136000 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -54,6 +54,8 @@ MCFunction::createFunctionFromMC(StringRef Name, const MCDisassembler *DisAsm,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Splits.insert(Index+Size);
|
Splits.insert(Index+Size);
|
||||||
|
} else if (Desc.isReturn()) {
|
||||||
|
Splits.insert(Index+Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Instructions.push_back(MCDecodedInst(Index, Size, Inst));
|
Instructions.push_back(MCDecodedInst(Index, Size, Inst));
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
|
#include "llvm/Support/GraphWriter.h"
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
@ -280,12 +281,28 @@ static void DisassembleInput(const StringRef &Filename) {
|
|||||||
Out << "digraph " << f.getName() << " {\n";
|
Out << "digraph " << f.getName() << " {\n";
|
||||||
Out << "graph [ rankdir = \"LR\" ];\n";
|
Out << "graph [ rankdir = \"LR\" ];\n";
|
||||||
for (MCFunction::iterator i = f.begin(), e = f.end(); i != e; ++i) {
|
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>";
|
Out << '"' << (uintptr_t)&i->second << "\" [ label=\"<a>";
|
||||||
// Print instructions.
|
// Print instructions.
|
||||||
for (unsigned ii = 0, ie = i->second.getInsts().size(); ii != ie;
|
for (unsigned ii = 0, ie = i->second.getInsts().size(); ii != ie;
|
||||||
++ii) {
|
++ii) {
|
||||||
IP->printInst(&i->second.getInsts()[ii].Inst, Out);
|
// Escape special chars and print the instruction in mnemonic form.
|
||||||
Out << '|';
|
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";
|
Out << "<o>\" shape=\"record\" ];\n";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user