jasmin
jasmin copied to clipboard
Remove unused return is not recursive
If removing a return reveals a new opportunity to remove a return, the compiler does not take advantage of it.
For instance,
fn g () -> reg u32 {
reg u32 x;
x = 0;
return x;
}
fn f () -> reg u32 {
reg u32 x;
x = g ();
return x;
}
export fn main () -> reg u32 {
reg u32 res;
res = 0;
_ = f();
return res;
}
The compiler removes the return value of f and thus could remove the return value of g, but it does not do it.
Here is a variant: the unused arguments are not removed.
fn id2(reg u32 x y) -> reg u32, reg u32 {
return x, y;
}
export
fn main(reg u32 a b) -> reg u32 {
a = a;
b += 42; //dead
a, _ = id2(a, b);
return a;
}