-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Latest rustc upstream (rust-lang/rust#78360) added a change that avoids creating StorageLive/StorageDead instructions if they are not required for codegen. Our previous assumption was that all locals (except arguments which live for the entirety of the function) have StorageLive and StorageDead instructions. This breaks our computation of live locals which are needed for stopgap interpreter initialisation.
For example, for the following function
fn guard(i: u8) -> u8 {
if i != 3 {
9
} else {
10
}
}previously, bb0 looked like this:
bb0: {
StorageLive(_2);
_2 = _1;
switchInt(move _2) -> [3_u8: bb2, otherwise: bb1];
}
In latest upstream, it looks like this:
bb0: {
_2 = _1;
switchInt(move _2) -> [3_u8: bb2, otherwise: bb1];
}
Since at this time we don't want to write our own liveness analysis (we all know how this turned out last time), a quick and dumb solution for this is to emit StorageLive for all locals at the beginning of a function, and StorageDead at the end of it (unless a local already has those). Ideally, this would be done during SIR lowering so there won't be a runtime cost.