Provide BB layout info externally in terms of code offsets.

This is sometimes useful when performing analyses on the generated
machine code: for example, some kinds of code verifiers will want to do
a control-flow analysis, and it is much easier to do this if one does
not have to recover the CFG from the machine code (doing so requires
heavyweight analysis when indirect branches are involved). If one trusts
the control-flow lowering and only needs to verify other properties of
the code, this can be very useful.
This commit is contained in:
Chris Fallin
2021-04-28 17:52:42 -07:00
committed by Chris Fallin
parent 76c6b83f6a
commit 11a2ef01e7
8 changed files with 81 additions and 7 deletions

View File

@@ -61,7 +61,7 @@ impl MachBackend for X64Backend {
let flags = self.flags();
let vcode = self.compile_vcode(func, flags.clone())?;
let buffer = vcode.emit();
let (buffer, bb_starts, bb_edges) = vcode.emit();
let buffer = buffer.finish();
let frame_size = vcode.frame_size();
let value_labels_ranges = vcode.value_labels_ranges();
@@ -79,6 +79,8 @@ impl MachBackend for X64Backend {
disasm,
value_labels_ranges,
stackslot_offsets,
bb_starts,
bb_edges,
})
}