Commit c156e4b
committed
Morph implicit byrefs after struct promotion
Change the phase ordering with respect to address-exposed analysis, struct
promotion, and implicit byref rewriting. This is done to subject implicit
byref parameters to struct promotion; when an implicit byref is to be
promoted, generate a new local of the struct type, promote it, and insert
code at method entry to initialize the new local by struct-copy from the
parameter. As part of the reordering, run address-exposed analysis before
implicit byref rewriting, so that the results of address-exposed analysis
can be consulted in determining whether promoting each implicit byref is
beneficial (in light of the cost of the struct copy), and effectively
avoid promoting those which are not deemed beneficial. This change treats
all implicit byref promotions as NOT beneficial; it reorders the phases
but produces no asm diffs. A subsequent change will identify beneficial
implicit byref promotions.
To make this work, the implicit byref rewriting happens in a few stages:
- fgMarkImplicitByRefArgs now does nothing more than flag which args are
implicit byrefs, and runs before struct promotion.
- fgRetypeImplicitByRefArgs actually retypes the parameters (from struct
to pointer), and decides which promotions are beneficial. It inserts
the initializing struct copies for beneficial ones, and annotates
non-beneficial ones so their appearances will be rewritten via the
pointer parameter. It runs after struct promotion and address-escape
analysis.
- fgMorphImplicitByRefArgs is moved out of fgMarkAddressExposedLocals,
and into fgMorphBlocks. It rewrites any implicit byref parameters
which have not been promoted to have the extra indirection at all their
references.
- fgMarkDemotedImplicitByRefArgs runs after fgMorphBlocks, and cleans up
some of the LclVarDsc annotations used to communicate across the
previous pieces.
Commit migrated from dotnet/coreclr@a6a8bd21 parent 57a3586 commit c156e4b
File tree
5 files changed
+565
-131
lines changed- src/coreclr/src/jit
5 files changed
+565
-131
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
| 717 | + | |
| 718 | + | |
717 | 719 | | |
718 | 720 | | |
719 | 721 | | |
| |||
4865 | 4867 | | |
4866 | 4868 | | |
4867 | 4869 | | |
| 4870 | + | |
| 4871 | + | |
4868 | 4872 | | |
4869 | | - | |
| 4873 | + | |
| 4874 | + | |
| 4875 | + | |
| 4876 | + | |
| 4877 | + | |
| 4878 | + | |
| 4879 | + | |
| 4880 | + | |
| 4881 | + | |
| 4882 | + | |
| 4883 | + | |
| 4884 | + | |
| 4885 | + | |
4870 | 4886 | | |
4871 | 4887 | | |
4872 | 4888 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10424 | 10424 | | |
10425 | 10425 | | |
10426 | 10426 | | |
10427 | | - | |
10428 | | - | |
| 10427 | + | |
| 10428 | + | |
| 10429 | + | |
| 10430 | + | |
| 10431 | + | |
| 10432 | + | |
| 10433 | + | |
| 10434 | + | |
| 10435 | + | |
| 10436 | + | |
| 10437 | + | |
10429 | 10438 | | |
10430 | 10439 | | |
10431 | 10440 | | |
| |||
11010 | 11019 | | |
11011 | 11020 | | |
11012 | 11021 | | |
11013 | | - | |
11014 | | - | |
11015 | | - | |
11016 | | - | |
11017 | | - | |
11018 | | - | |
| 11022 | + | |
11019 | 11023 | | |
11020 | | - | |
11021 | | - | |
11022 | | - | |
11023 | | - | |
| 11024 | + | |
| 11025 | + | |
| 11026 | + | |
| 11027 | + | |
| 11028 | + | |
| 11029 | + | |
| 11030 | + | |
| 11031 | + | |
| 11032 | + | |
| 11033 | + | |
11024 | 11034 | | |
11025 | | - | |
11026 | | - | |
11027 | | - | |
| 11035 | + | |
| 11036 | + | |
| 11037 | + | |
| 11038 | + | |
| 11039 | + | |
| 11040 | + | |
| 11041 | + | |
| 11042 | + | |
11028 | 11043 | | |
11029 | | - | |
11030 | | - | |
11031 | | - | |
11032 | | - | |
| 11044 | + | |
| 11045 | + | |
| 11046 | + | |
| 11047 | + | |
11033 | 11048 | | |
11034 | | - | |
11035 | | - | |
11036 | | - | |
11037 | | - | |
11038 | | - | |
11039 | | - | |
| 11049 | + | |
| 11050 | + | |
| 11051 | + | |
| 11052 | + | |
| 11053 | + | |
| 11054 | + | |
11040 | 11055 | | |
11041 | | - | |
11042 | | - | |
11043 | | - | |
11044 | | - | |
11045 | | - | |
| 11056 | + | |
| 11057 | + | |
| 11058 | + | |
| 11059 | + | |
| 11060 | + | |
11046 | 11061 | | |
11047 | | - | |
11048 | | - | |
11049 | | - | |
11050 | | - | |
| 11062 | + | |
| 11063 | + | |
| 11064 | + | |
| 11065 | + | |
| 11066 | + | |
11051 | 11067 | | |
11052 | 11068 | | |
11053 | 11069 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1818 | 1818 | | |
1819 | 1819 | | |
1820 | 1820 | | |
1821 | | - | |
| 1821 | + | |
1822 | 1822 | | |
1823 | 1823 | | |
1824 | 1824 | | |
| |||
1924 | 1924 | | |
1925 | 1925 | | |
1926 | 1926 | | |
| 1927 | + | |
1927 | 1928 | | |
1928 | 1929 | | |
1929 | 1930 | | |
| |||
0 commit comments