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)
commit4d6632a039067eb6853e22b586c57136eb94943a
tree6b113d6f92e514848db28ba45cd4b0e40b1ca930
parent88decba4a23c6a73d3e648e76bd54b778f0eee60
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 dotnet/coreclr#10780.

Commit migrated from https://github.com/dotnet/coreclr/commit/673f56aa91d69b78fc0055e4419d5ad59c47b83b
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/gentree.h
src/coreclr/src/jit/importer.cpp
src/coreclr/src/jit/morph.cpp
src/coreclr/src/jit/optimizer.cpp
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_10780/GitHub_10780.cs [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_10780/GitHub_10780.csproj [new file with mode: 0644]