@@ -70,11 +70,6 @@ Current Representation of Struct Values
70
70
71
71
These struct-typed nodes are created by the importer, but transformed in morph, and so are not
72
72
encountered by most phases of the JIT:
73
- * ` GT_INDEX ` : This is transformed to a ` GT_IND `
74
- * Currently, the IND is marked with ` GTF_IND_ARR_INDEX ` and the node pointer of the ` GT_IND ` acts as a key
75
- into the array info map.
76
- * Proposed: This should be transformed into a ` GT_OBJ ` when it represents a struct type, and then the
77
- class handle would no longer need to be obtained from the array info map.
78
73
* ` GT_FIELD ` : This is transformed to a ` GT_LCL_VAR ` by the ` Compiler::fgMarkAddressExposedLocals() ` phase
79
74
if it's a promoted struct field, or to a ` GT_LCL_FLD ` or GT_IND` by ` fgMorphField()`.
80
75
* Proposed: A non-promoted struct typed field should be transformed into a ` GT_OBJ ` , so that consistently all struct
@@ -90,9 +85,7 @@ encountered by most phases of the JIT:
90
85
### Struct “objects” as lvalues
91
86
92
87
* The lhs of a struct assignment is a block or local node:
93
- * ` GT_OBJ ` nodes represent the “shape” info via a struct handle, along with the GC info
94
- (location and type of GC references within the struct).
95
- * These are currently used only to represent struct values that contain GC references (although see below).
88
+ * ` GT_OBJ ` nodes represent struct types with a handle, and store a pointer to the ` ClassLayout ` object.
96
89
* ` GT_BLK ` nodes represent struct types with no GC references, or opaque blocks of fixed size.
97
90
* These have no struct handle, resulting in some pessimization or even incorrect
98
91
code when the appropriate struct handle can't be determined.
@@ -101,12 +94,12 @@ encountered by most phases of the JIT:
101
94
[ #21705 ] ( https://github.com/dotnet/coreclr/pull/21705 ) they are no longer large nodes.
102
95
* ` GT_STORE_OBJ ` and ` GT_STORE_BLK ` have the same structure as ` GT_OBJ ` and ` GT_BLK ` , respectively
103
96
* ` Data() ` is op2
104
- * ` GT_DYN_BLK ` and ` GT_STORE_DYN_BLK ` (GenTreeDynBlk extends GenTreeBlk)
97
+ * ` GT_STORE_DYN_BLK ` (GenTreeStoreDynBlk extends GenTreeBlk)
105
98
* Additional child ` gtDynamicSize `
106
- * Note that these aren't really struct types ; they represent dynamically sized blocks
99
+ * Note that these aren't really struct stores ; they represent dynamically sized blocks
107
100
of arbitrary data.
108
- * For ` GT_LCL_FLD ` nodes, we don't retain shape information, except indirectly via the ` FieldSeqNode ` .
109
- * For ` GT_LCL_VAR ` nodes, the` ClassLayout ` is obtained from the ` LclVarDsc ` .
101
+ * For ` GT_LCL_FLD ` nodes, we store a pointer to ` ClassLayout ` in the node .
102
+ * For ` GT_LCL_VAR ` nodes, the ` ClassLayout ` is obtained from the ` LclVarDsc ` .
110
103
111
104
### Struct “objects” as rvalues
112
105
@@ -131,10 +124,6 @@ After morph, a struct-typed value on the RHS of assignment is one of:
131
124
* ` GT_CALL `
132
125
* ` GT_LCL_VAR `
133
126
* ` GT_LCL_FLD `
134
- * Note: With ` compDoOldStructRetyping() ` , a GT_LCL_FLD` with a primitive type of the same size as the struct
135
- is used to represent a reference to the full struct when it is passed in a register.
136
- This forces the struct to live on the stack, and makes it more difficult to optimize these struct values,
137
- which is why this mechanism is being phased out.
138
127
* ` GT_SIMD `
139
128
* ` GT_OBJ ` nodes can also be used as rvalues when they are call arguments
140
129
* Proposed: ` GT_OBJ ` nodes can be used in any context where a struct rvalue or lvalue might occur,
@@ -173,8 +162,7 @@ There are three main phases in the JIT that make changes to the representation o
173
162
registers. The necessary transformations for correct code generation would be
174
163
made in ` Lowering ` .
175
164
176
- * With ` compDoOldStructRetyping() ` , if it is passed in a single register, it is morphed into a
177
- ` GT_LCL_FLD ` node of the appropriate primitive type.
165
+ * If it is passed in a single register, it is morphed into a ` GT_LCL_FLD ` node of the appropriate primitive type.
178
166
* This may involve making a copy, if the size cannot be safely loaded.
179
167
* Proposed: This would remain a ` GT_OBJ ` and would be appropriately transformed in ` Lowering ` ,
180
168
e.g. using ` GT_BITCAST ` .
@@ -310,22 +298,13 @@ This would be enabled first by [Defer ABI-specific transformations to Lowering](
310
298
for block copies. See [ \# 21711 Improve init/copy block codegen] ( https://github.com/dotnet/coreclr/pull/21711 ) .
311
299
312
300
* This also includes cleanup of the block morphing methods such that block nodes needn't be visited multiple
313
- times, such as ` fgMorphBlkToInd ` (may be simply unneeded), ` fgMorphBlkNode ` and ` fgMorphBlkOperand ` .
301
+ times, such as ` fgMorphBlkNode ` and ` fgMorphBlkOperand ` .
314
302
These methods were introduced to preserve old behavior, but should be simplified.
315
303
316
- * Somewhat related is the handling of struct-typed array elements. Currently, after the ` GT_INDEX ` is transformed
317
- into a ` GT_IND ` , that node must be retained as the key into the ` ArrayInfoMap ` . For structs, this is then
318
- wrapped in ` OBJ(ADDR(...)) ` . We should be able to change the IND to OBJ and avoid wrapping, and should also be
319
- able to remove the class handle from the array info map and instead used the one provided by the ` GT_OBJ ` .
320
-
321
304
### Miscellaneous Cleanup
322
305
323
306
These are all marked with ` TODO-1stClassStructs ` or ` TODO-Cleanup ` in the last case:
324
307
325
- * The handling of ` DYN_BLK ` is unnecessarily complicated to duplicate previous behavior (i.e. to enable previous
326
- refactorings to be zero-diff). These nodes are infrequent so the special handling should just be eliminated
327
- (e.g. see ` GenTree::GetChild() ` ).
328
-
329
308
* The checking at the end of ` gtNewTempAssign() ` should be simplified.
330
309
331
310
* When we create a struct assignment, we use ` impAssignStruct() ` . This code will, in some cases, create
0 commit comments