What happens in cranelift if I do something like
b0:
...
brz b2
fallthrough b1
b1:
a = ...
jmp b3
b2:
... does not define a ...
jmp b3
b3:
use a
Is this a bug? Or will a
be used uninitialized when b0->b2->b3
path is
taken? Where do I look for the relevant code that this is handled?
I just tried this, and it seems like cranelift initializes the variable with 0 so it's initialized in all paths:
function u0:0() -> i64 system_v {
block3:
v5 = iconst.i64 0
v4 -> v5
v0 = iconst.i64 123
v1 = iconst.i64 456
br_icmp eq v0, v1, block0
jump block1
block0:
jump block2(v5)
block1:
v2 = iconst.i64 999
jump block2(v2)
block2(v3: i64):
return v3
}
I'd still like to see where this happens. Any pointers?
This is done by cranelift_frontend::ssa::emit_zero
.
Last updated: Dec 23 2024 at 12:05 UTC