Skip to main content

addresses

Function addresses 

Source
pub fn addresses(
    func: &mut Func,
    insts: &FrameInsts,
    machine: &MachineInsts,
    names: &mut Interner,
    pending: &mut Pending<'_>,
) -> usize
Expand description

Folds every address computation that one memory operand reads, and gives back how many.

pending is the addresses crate::finish has still to write a displacement into, and folding one moves its entry to the instruction that took it. The displacement composed in by the fold stays where it is and the frame’s offset is added to it later, which is why that write is an addition rather than an assignment.

Run after lowering and before allocation, and run once. Running it twice can find more than running it once in principle: folding a lea into a second lea leaves that second one foldable in turn, and the walk below takes those in the one pass since it goes forwards, but it does not take the other order, where the second lea has a reader of its own and goes before the first one’s set is complete, and that is a set a second run would find whole.

Measured, it finds nothing. Running this to a fixed point is the same instruction count over the corpus at every level and one instruction more over the SQLite amalgamation, which is the allocator taking a different tie break somewhere rather than a fold. So the pipeline runs it once and this note is here so the next person to notice the same thing does not have to build it to find out.