Stop hoisting statics above cctors
authorJoseph Tremoulet <jotrem@microsoft.com>
Tue, 9 May 2017 02:30:04 +0000 (22:30 -0400)
committerJoseph Tremoulet <jotrem@microsoft.com>
Tue, 9 May 2017 21:59:19 +0000 (17:59 -0400)
commit673f56aa91d69b78fc0055e4419d5ad59c47b83b
tree5af35f7b2f5b841b99d29b3bba4eb70d3235394c
parenteac27ca7fb6e80a0a1af44b889469b2818c45a9a
Stop hoisting statics above cctors

Extend the logic in optLoopHoist around `CLS_VAR` nodes to ensure we don't
hoist any tree that contains a `CLS_VAR` for a field with the flag
`CORINFO_FLG_FIELD_INITCLASS` set, unless we also (identify and) hoist the
corresponding static init helper call.  The previous logic was
insufficient in that it blocked hoisting of singleton `CLS_VAR` nodes, but
not hoisting of trees that contain `CLS_VAR` nodes as sub-trees.

Add flag `GTF_FLD_INITCLASS`/`GTF_CLS_VAR_INITCLASS` so that optLoopHoist
can recall which fields are paired with static init helper calls, and only
block the hoisting of their trees.

Fixes #10780.
src/jit/compiler.h
src/jit/gentree.h
src/jit/importer.cpp
src/jit/morph.cpp
src/jit/optimizer.cpp
tests/src/JIT/Regression/JitBlue/GitHub_10780/GitHub_10780.cs [new file with mode: 0644]
tests/src/JIT/Regression/JitBlue/GitHub_10780/GitHub_10780.csproj [new file with mode: 0644]