This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
Fix InitializeArray intrinsic must always be expanded for CoreRT. #14401
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue is dotnet/corert#4690.
The problem is the same as the old one(#10215), we do spill because reach the max tree size.
impInitializeArrayIntrinsic
relies that the last stmt is the helper call.We violate it if
MAX_TREE
spill happens before dbg spill on the stmt boundaries. We ends up with the wrong stmt order and can't import the intrinsic.It works with optimization because we force to spill after 'dup' that are not 'elementary' and the right spills happen before we spill because of
MAX_TREE_SIZE
.The good example:
The last statement is
[000019]
.The bad example:
in the bad example we do not spill
[000280]
because it is leaf node, that we ignorebut then this leave is spilled for dbg code and
000280
becomes the last statement.I see 3 possible cheap fixes:
new_arr
,new_obj
;impInitializeArrayIntrinsic
;I do not like the second variant, because it creates additional checks in the
impInitializeArrayIntrinsic
.The third variant is good, possible that there are other intrinsics that will benefit from the right order, but it causes asm diffs in CoreCLR.
So this PR implements the first variant as the cheapest to implement and check.
It is safe not to add
dup
into this list, because it doesn't add new stmt or locals. It is important not to add it, because we can create a test, that will cause stack overflow with such exclusion.