IR validation pass
Currently if the input IR is incorrect, one of the following may happen:
- some assertion in the compiler may fail
- Rust safety finds it and panics (such as index out of bounds)
- the compiler generates correct or incorrect code even if input IR is incorrect
We will want a IR validation pass to check the input IR. It includes:
- check if types and numbers of operands and results of each instructions match
- check if function signatures matches parameters and return values
- check if branch arguments matches parameters, and if branch destination is valid
- check if the last instruction for each block is terminating instruction (
BRNACH
,CALL
,RET
, etc) ...
(this list will grow when I think up more)