This repository was archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Verifier #3
Copy link
Copy link
Closed
Description
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
VOIDfirst_type(). - All referenced entities must exist. (Values, EBBs, stack slots, ...)
EBB integrity:
- All instructions reached from the
ebb_instsiterator must belong to the EBB as reported byinst_ebb(). - Should we detect loops in the
ebb_instsiterator? 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_argsiterator belongs to the EBB as reported byvalue_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_tablemust 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
returninstructions 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels