Skip to main content

pads

Function pads 

Source
pub fn pads(
    func: &mut Func,
    frame: &FrameInsts,
    landing: Option<&'static str>,
    names: &mut Interner,
) -> usize
Expand description

Puts a landing pad at the front of every block whose address is taken, and gives back how many it wrote.

Run after indirect, because the block an address names is not settled until that has moved the addresses on to the blocks it made, and only when the command line asked for the forward edge to be checked. Nothing is written otherwise, which is why the name comes in as an option and why a target with no such instruction is a target this does nothing on.

The pad a prologue opens with is written elsewhere, in crate::finish, because the address it makes reachable is the address of the function rather than a place inside it. These are the other addresses an indirect branch may arrive at, and a machine that checks the forward edge faults on one that has no pad, so a computed goto compiled without this would be a program that ran everywhere except on the hardware the flag was turned on for.