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:
26
cranelift/filetests/verifier/return_at_end.cton
Normal file
26
cranelift/filetests/verifier/return_at_end.cton
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user