Commit Graph

10 Commits

Author SHA1 Message Date
Ahmed Bougacha ff12d02d51 MC CFG: Split MCBasicBlocks to mirror atom splitting.
When an MCTextAtom is split, all MCBasicBlocks backed by it are
automatically split, with a fallthrough between both blocks, and
the successors moved to the second block.

llvm-svn: 188881
2013-08-21 07:28:24 +00:00
Ahmed Bougacha d3fc5b9648 MC CFG: Add a few needed methods, mainly MCModule::findFirstAtomAfter.
While there, do some minor cleanup.

llvm-svn: 188880
2013-08-21 07:28:17 +00:00
Ahmed Bougacha 7bfc7da6e8 MC CFG: Keep pointer to parent MCModule in created MCFunctions.
Also, drive-by cleaning around createFunction.

llvm-svn: 188875
2013-08-21 07:27:55 +00:00
Ahmed Bougacha 555575c32b Revert "Remove use of asymmetric std::lower_bound comparator."
This reverts commit r185676.
Originally done because of VS 2008.

llvm-svn: 186969
2013-07-23 17:44:11 +00:00
Ahmed Bougacha 156a2deafe Remove use of asymmetric std::lower_bound comparator.
VS 2008 doesn't like it when in debug mode.

llvm-svn: 185676
2013-07-04 23:20:12 +00:00
Ahmed Bougacha 8a5e10555a Allow creation of single-byte MCAtoms.
llvm-svn: 184344
2013-06-19 20:18:59 +00:00
Daniel Jasper 01a8079bf2 Fix unused warning in opt builds.
In these builds, the asserts() are completely compiled out of the code
leaving "End" unused. Directly accessing it, should not have a
performance impact, as it is just a data member.

llvm-svn: 182634
2013-05-24 06:26:18 +00:00
Ahmed Bougacha aa79068157 MC: Disassembled CFG reconstruction.
This patch builds on some existing code to do CFG reconstruction from
a disassembled binary:
- MCModule represents the binary, and has a list of MCAtoms.
- MCAtom represents either disassembled instructions (MCTextAtom), or
  contiguous data (MCDataAtom), and covers a specific range of addresses.
- MCBasicBlock and MCFunction form the reconstructed CFG. An MCBB is
  backed by an MCTextAtom, and has the usual successors/predecessors.
- MCObjectDisassembler creates a module from an ObjectFile using a
  disassembler. It first builds an atom for each section. It can also
  construct the CFG, and this splits the text atoms into basic blocks.

MCModule and MCAtom were only sketched out; MCFunction and MCBB were
implemented under the experimental "-cfg" llvm-objdump -macho option.
This cleans them up for further use; llvm-objdump -d -cfg now generates
graphviz files for each function found in the binary.

In the future, MCObjectDisassembler may be the right place to do
"intelligent" disassembly: for example, handling constant islands is just
a matter of splitting the atom, using information that may be available
in the ObjectFile. Also, better initial atom formation than just using
sections is possible using symbols (and things like Mach-O's
function_starts load command).

This brings two minor regressions in llvm-objdump -macho -cfg:
- The printing of a relocation's referenced symbol.
- An annotation on loop BBs, i.e., which are their own successor.

Relocation printing is replaced by the MCSymbolizer; the basic CFG
annotation will be superseded by more related functionality.

llvm-svn: 182628
2013-05-24 01:07:04 +00:00
Jim Grosbach 0dde349df1 Tidy up. 80 columns.
llvm-svn: 144649
2011-11-15 16:46:22 +00:00
Owen Anderson 6cca67fc4a Start stubbing out MCModule and MCAtom, which provide an API for accessing the rich disassembly of a complete object or executable.
These are very much a work in progress, and not really useful yet.

llvm-svn: 140345
2011-09-22 22:32:22 +00:00