Files
wasmtime/cranelift/filetests/regalloc/unreachable_code.cton
Jakob Stoklund Olesen 90ed698e83 Add an unreachable code elimination pass.
The register allocator doesn't even try to compile unreachable EBBs, so
any values defined in such blocks won't be assigned registers.

Since the dominator tree already has determined which EBBs are
reachable, we should just eliminate any unreachable blocks instead o
trying to do something with the dead code.

Not that this is not a "dead code elimination" pass which would also
remove individual instructions whose results are not used.
2017-10-09 15:26:27 -07:00

46 lines
652 B
Plaintext

test compile
set is_64bit
isa intel haswell
; This function contains unreachable blocks which trip up the register
; allocator if they don't get cleared out.
function %unreachable_blocks(i64 vmctx) -> i32 spiderwasm {
ebb0(v0: i64):
v1 = iconst.i32 0
v2 = iconst.i32 0
jump ebb2
ebb2:
jump ebb4
ebb4:
jump ebb2
; Everything below this point is unreachable.
ebb3(v3: i32):
v5 = iadd.i32 v2, v3
jump ebb6
ebb6:
jump ebb6
ebb7(v6: i32):
v7 = iadd.i32 v5, v6
jump ebb8
ebb8:
jump ebb10
ebb10:
jump ebb8
ebb9(v8: i32):
v10 = iadd.i32 v7, v8
jump ebb1(v10)
ebb1(v11: i32):
return v11
}