Add a return_at_end setting.

The flag guarantees that the generated function does not have any
internal return instructions. If the function returns at all, the return
must be the last instruction.

For now just implement a verifier check for this property. When we get
CFG simplifiers and block layout optimizations, they will need to heed
the flag.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-11 11:04:38 -07:00
parent 7bf2747e1e
commit 25af6d380b
5 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
test verifier
set return_at_end
; The verifier doesn't have an API for verifying with flags without also
; setting an ISA.
isa riscv
function %ok(i32) {
ebb0(v0: i32):
brnz v0, ebb1
trap
ebb1:
trapz v0
return
}
function %bad(i32) {
ebb0(v0: i32):
brnz v0, ebb1
return ; error: Internal return not allowed
ebb1:
trapz v0
return
}