Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Verifier #3

@stoklund

Description

@stoklund

Cretonne needs an IR verifier.

The verifier can be run before and after different passes. It checks those IR invariants that are not enforced by the type system.

Instruction integrity:

  • The instruction format must match the opcode.
  • All result values must be created for multi-valued instructions.
  • Instructions with no results must have a VOID first_type().
  • All referenced entities must exist. (Values, EBBs, stack slots, ...)

EBB integrity:

  • All instructions reached from the ebb_insts iterator must belong to the EBB as reported by inst_ebb().
  • Should we detect loops in the ebb_insts iterator? The current linked list representation could theoretically do it.
  • Every EBB must end in a terminator instruction, and no other instruction can be a terminator.
  • Every value in the ebb_args iterator belongs to the EBB as reported by value_ebb.

SSA form. All values used by an instruction must:

  • Be defined by an instruction that exists and that is inserted in an EBB, or be an argument of an existing EBB.
  • Dominate the instruction. This check should probably be skipped for EBBs that can't be reached from the entry.

Control flow graph and dominator tree integrity.

  • All predecessors in the CFG must be branches to the EBB.
  • All branches to an EBB must be present in the CFG.
  • A recomputed dominator tree is identical to the existing one.

Type checking:

  • Verify all input and output values against the opcode's type constraints. For polymorphic opcodes, determine the controlling type variable first.
  • Branches and jumps must pass arguments to destination EBBs that match the expected types excatly. The number of arguments must match.
  • All EBBs in a jump_table must take no arguments.
  • Function calls are type checked against their signature.
  • The entry block must take arguments that match the signature of the current function.
  • All return instructions must have return value operands matching the current function signature.

Ad hoc checking:

  • Stack slot loads and stores must be in-bounds.
  • Immediate constraints for certain opcodes, like udiv_imm v3, 0.
  • Extend / truncate instructions have more type constraints: Source type can't be larger / smaller than result type.

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