Skip to content

[WARP] Blacklisted instructions (NOPs, self-moves) are still hashed into the basic block GUID #8734

Backlog

Description

@BiNeurale

The WARP README says the basic block GUID excludes NOP instructions and register self-moves, and the doc comment on is_blacklisted_instruction in plugins/warp/src/lib.rs says the same ("Is the instruction not included in the masked byte sequence?"). In the current code those bytes are included.

In basic_block_guid (dev f32bb49, lines 209-248) the blacklist check is inside the inner loop over the lifted IL instructions:

for lifted_il_instr in filtered_instructions_at(lifted_il, instr_addr) {
    // If instruction is blacklisted, don't include the bytes.
    if is_blacklisted_instruction(&lifted_il_instr) {
        continue;
    }
    ...
}
...
basic_block_bytes.extend(instr_bytes);

so continue only moves to the next IL instruction and the bytes are appended anyway. Before 88eba55 ("Fix possible skipped instructions when multiple IL expressions are appended for a given instruction") this was an if let and the continue skipped the whole instruction, so I think this changed by accident.

The test fixture in the repo shows it. In plugins/warp/fixtures/bin/ls the function at 0x40f1b8 is

nop; nop; ldr x0, [x0, #24]; ret

and determinism__ls.snap has c5cd18ed-5acb-5ab1-ac04-1d79889adced for it. That is the GUID of the bytes 1f2003d5 1f2003d5 000c40f9 c0035fd6. With the NOPs left out (000c40f9 c0035fd6) the GUID would be 5891fc95-6609-5bf7-a325-170c0c66eddc. I recomputed 23 simple functions from that snapshot and all 12 that contain a NOP only match with the NOP bytes kept.

The render layer also highlights these instructions as blacklisted, so it currently suggests they are excluded when they are not.

A labeled continue 'instr; on the outer loop would restore the documented behavior, but it changes the GUID of every function that contains a NOP, so signatures generated since 5.1 would stop matching those functions. If you prefer to keep the current GUIDs, updating the README and the doc comments would also fix the mismatch. I'm happy to send either change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions