JIT: Update GTF_GLOB_REF after last-use copy omission (#81430)
authorJakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
Wed, 1 Feb 2023 21:34:28 +0000 (22:34 +0100)
committerGitHub <noreply@github.com>
Wed, 1 Feb 2023 21:34:28 +0000 (22:34 +0100)
commit58176f5c524747680e6261150e2ecfa98a383c16
treed89418bad0ac8e3023f04142f356b3428b47a746
parenteadf678c8e9749938f6c11830288bc061c0b8030
JIT: Update GTF_GLOB_REF after last-use copy omission (#81430)

Morph is responsible for marking accesses of address-exposed locals with
GTF_GLOB_REF, however the last-use copy elision can newly address expose
a preexisting local. This means previous uses that morph already saw
have not had GTF_GLOB_REF added. This updates the JIT to at least add
GTF_GLOB_REF on locals within the same statement as the call. This is
not a complete fix as nothing prevents downstream phases from reordering
the call with uses from earlier statements, but this at least fixes the
one issue we know of right now (which is itself stress-only).

A more complete fix will likely entail moving the identifying of
last-use candidates earlier and address exposing them at that point.
However, that first requires ABI determination to be moved earlier, so
this depends on #76926, which I expect to get to within the near future.

Fix #81049
src/coreclr/jit/compiler.h
src/coreclr/jit/morph.cpp