Skip to content

Latent LIR branch bug in Option D LoadAttrCached inline fast path #11

Description

@SonicField

Bug

appendBranch(Instruction::kBranch, done_block) in the Option D LoadAttrCached inline fast path (cinderx/Jit/lir/generator.cpp) creates a branch instruction with NO label operand.

Current behaviour

Works by accident: the post-alloc pass skips blocks that already have a kBranch, and block ordering happens to make done_block the immediate fall-through successor.

Risk

If block ordering changes (e.g., during future optimisation passes), the branch has no target and will either:

  • Jump to wrong code
  • Trigger LIR verifier failure (in debug builds)

Root cause

appendBranch(kBranch, done_block) creates a branch to done_block but does not attach a label operand. The post-alloc pass (postalloc.cpp:427) skips blocks that already have a kBranch, so no label is ever added.

Fix

Replace appendBranch(kBranch, done_block) with either:

  1. Explicit fall-through via block ordering (appendBlock)
  2. Add a label operand to the branch instruction

Priority

Low — code is functionally correct today. All 42 LOAD_ATTR tests and 30/33 generator tests pass.

Commit

3c4ff94 on branch aarch64-jit-generators

Files

  • cinderx/Jit/lir/generator.cpp (kLoadAttrCached case, incref_block and call_block sections)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions