Skip to content

Validate phi inputs against predecessor edges #80

Closed

Description

@LunaStev

Current evidence

Audit baseline: master 3ac33ec1, after #11. Source: ir/src/verifier.rs:161.

Static inspection: phi inputs are treated as ordinary sequential uses. Incoming block IDs, predecessor completeness, duplicate edges and incoming types are not checked; valid backedge definitions may be rejected solely because their block is stored later.

Scope

Difficulty: high.

Give phi nodes edge-specific validation and a defined placement rule. Coordinate with CFG/dominance validation without combining unrelated instruction checks.

Completion criteria

  • Incoming blocks correspond to actual predecessor edges.
  • Duplicate/missing incoming edges and wrong incoming types fail.
  • A valid loop phi referencing a backedge value passes.
  • Tests reorder blocks while preserving the CFG.

Dependencies and boundaries

#45

Backlog index: #12. This issue owns only the bounded work described above.

Approved D11 contract — 2026-09-23

The maintainer approved the following CFG rules:

  • Phi instructions form a prefix at the beginning of a block.
  • Each phi has exactly one input for each distinct predecessor block, even if that predecessor has repeated successor edges.
  • The function entry block has neither phi instructions nor predecessor edges. Reject entry self-loops and incoming edges from reachable or unreachable blocks, for br, conditional branches, and switch destinations.
  • Ordinary loops use separate loop-header blocks and remain supported, including valid backedge phi inputs.
  • Verification preserves the original O0 module without rewriting or removing its blocks.

These requirements are implemented in the local foundation work and have regression coverage, including block-order permutations. They are not yet committed or merged; this issue remains open.

Activity

  1. added
    bug
    help wanted
    ir
    needs testing
    priority high
    on Sep 18, 2026
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

    bughelp wantedirneeds testingpriority high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions