Open Skasselbard opened 4 years ago
As far as I know this is deliberate. Cc @rust-lang/wg-mir-opt for some MIR experts.
This is arguably a bug, although for codegen this doesn't usually matter since _3
is never on the stack.
That's not a reason to not have Storage{Live,Dead}
but rather why this hasn't caused enough problems to be changed. IIUC, only miri would take advantage of Storage{Live,Dead}
for _3
.
I saw something similar in other places. If I remember correctly the return place of intrinsic and/or foreign functions (like calls to the pthread library in mutexes) missed the storage statements as well.
Something like the _x
in this pseudo mir:
bbn:
// statements
_x = ffcall() -> somebb
}
From my point of view, the mir graph is a nice intermediate representation that can act as source for a translation to other targets. Especially because all code generation (macros and generics) was done in previous compiler phases and because there are only few language constructs that have to be translated (mainly statements and terminators). I used it as source to translate into Petri-Nets for verification purposes.
If you see mir as a simple machine-readable source representation as base for all kind of translations (and not just as a component of the compiler), it makes sense to stay consistent (or document a rule that describes this behaviour). Even though it might not impact the compilation process.
It seems that the StorageLive and StorageDead statements are not generated for every local of a function.
I tried this code:
I expected to see something like this happen:
Instead, this happened:
Meta
rustc --version --verbose
: rustc 1.41.0-nightly (25d8a9494 2019-11-29) binary: rustc commit-hash: 25d8a9494ca6d77361e47c1505ecf640b168819e commit-date: 2019-11-29 host: x86_64-unknown-linux-gnu release: 1.41.0-nightly LLVM version: 9.0Reproducable on [Rust Playgound](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=pub%20fn%20main()%20%7B%0A%20%20%20%20let%20mut%20x%20%3D%205%3B%0A%20%20%20%20x%20%3D%20call(x)%3B%0A%7D%0A%0Afn%20call(i%3A%20usize)%20-%3E%20usize%20%7B%0A%20%20%20%20i%20*%202%0A%7D%0A) in stable and nightly channel