Don't allow EBB parameters to be ghost values.

Ghost instructions and values are supposed to be stored as metadata
alongside the compiled program such that the ghost values can be
computed from the real register/stack values when the program is stopped
for debugging or de-optimization.

If we allow an EBB parameter to be a ghost value, we have no way of
computing its real value using ghost instructions. We would need to know
a complete execution trace of the stopped program to figure out which
values were passed to the ghost parameter.

Instead we require EBB parameters to be real values materialized in
registers or on the stack. We use the regclass_for_abi_type() TargetIsa
callback to determine the initial register class for these parameters.
They can then be spilled later if needed.

Fixes #215.
This commit is contained in:
Jakob Stoklund Olesen
2018-01-11 16:35:19 -08:00
parent 5e094034d4
commit cacba1a58f
3 changed files with 48 additions and 86 deletions

View File

@@ -0,0 +1,43 @@
test regalloc
set is_64bit
isa intel haswell
; This test case would create an EBB parameter that was a ghost value.
; The coalescer would insert a copy of the ghost value, leading to verifier errors.
;
; We don't allow EBB parameters to be ghost values any longer.
;
; Test case by binaryen fuzzer!
function %pr215(i64 vmctx [%rdi]) native {
ebb0(v0: i64):
v10 = iconst.i64 0
v1 = bitcast.f64 v10
jump ebb5(v1)
ebb5(v9: f64):
v11 = iconst.i64 0xffff_ffff_ff9a_421a
v4 = bitcast.f64 v11
v6 = iconst.i32 0
v7 = iconst.i32 1
brnz v7, ebb4(v6)
v8 = iconst.i32 0
jump ebb7(v8)
ebb7(v5: i32):
brnz v5, ebb3(v4)
jump ebb5(v4)
ebb4(v3: i32):
brnz v3, ebb2
jump ebb3(v9)
ebb3(v2: f64):
jump ebb2
ebb2:
jump ebb1
ebb1:
return
}