Expand Virtual Call targets earlier in Morph and allow CSE of the indirections (...
authorBrian Sullivan <briansul@microsoft.com>
Tue, 16 Feb 2021 00:27:18 +0000 (16:27 -0800)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 00:27:18 +0000 (16:27 -0800)
commit02b7358cd5f07d0492e99a32c29544a62a292ad8
tree378fd708075ff1fdb77eb8659f35f8b8aec9f60f
parent2e36f1b3a81a2d43d0c0d3597a7ead1bcda35a27
Expand Virtual Call targets earlier in Morph and allow CSE of the indirections (#47808)

* Added GTF_CALL_M_EXPANDED_EARLY to flag virtual calls that should be expanded early during fgMorph
Added COMPlus_JitExpandCallsEarly variable to enable virtual calls to be expanded early on a per method basis
Set opts.compExpandCallsEarly to true when we are optimizing and have COMPlus_JitExpandCallsEarly enabled
Update gtSetEvalOrder to also include the call->gtControlExpr
Update morph to call fgExpandVirtualVtableCallTarget when we are expanding early
Update lower to not call LowerVirtualVtableCall when we have already expanded it early
Modify CheckTreeId to print the duplicated gtTreeID before it asserts.

All tests are passing when using COMPLUS_JitExpandCallsEarly=*

Expand the Virtual Call target after we morph the args
Fix an inadvertent change in the GT_CALL weights

* Changed the default for Virtual calls to be expanded early in Morph
Use COMPlus_JitExpandCallsEarly=0 to disable and use old behavior

* Code Review feedback
Added comment stating the the isRelative code path is never executed

* Fixes for propagating gtControlExpr->gtFlags

* Fix a few code size regressions when we perform a tail call

* Tailcall lower fix

* Code Review changes

* Fixes for the TAILCALL_HELPER path for x86

* Address the Arm/Linux failure
src/coreclr/jit/compiler.cpp
src/coreclr/jit/compiler.h
src/coreclr/jit/fgdiagnostic.cpp
src/coreclr/jit/gentree.cpp
src/coreclr/jit/gentree.h
src/coreclr/jit/importer.cpp
src/coreclr/jit/jitconfigvalues.h
src/coreclr/jit/lower.cpp
src/coreclr/jit/morph.cpp