Closed tyfkda closed 11 months ago
int foo(int x) { char arr[100]; if (x >= 0) return x; else return -x; }
;;=== 0x50: CODE, len=53 (func $foo (;0;) (type 0) (local i32) global.get 0 local.set 1 global.get 0 i32.const 104 i32.sub global.set 0 block (result i32) local.get 0 i32.const 0 i32.ge_s if local.get 0 br 1 ;; <= here else i32.const 0 local.get 0 i32.sub br 1 ;; <= here end unreachable ;; <= here end local.get 1 global.set 0 )
return statements in last if statement are not treated as at function-end, so return or br instruction is put to exit from function.
return
if
br
return
statements in lastif
statement are not treated as at function-end, soreturn
orbr
instruction is put to exit from function.