-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper VNs for zeroed structs #61285
Proper VNs for zeroed structs #61285
Conversation
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsPreviously, zero-initialized struct locals were given a special This change introduces a new There are almost no diffs for this change because of some other deficiencies in assertion and copy propagation, they are being/will be fixed separately, so the main point of this change is to contribute to #58312. Part of #58312.
|
a6f1b90
to
0d5a6c0
Compare
Previously, zero-initialized struct locals were given a special $VNForZeroMap, which had the nice property that VNForMapSelect($VNForZeroMap, Field) would always return zero of the appropriate type. However, the fact that this VN is not unique meant that it was dangerous to propagate it, e. g. through copies, which was hidden by the fact that ApplySelectorsTypeCheck's logic is very conservative. This change introduces a new VNFunc to represent zeroed objects - VNF_ZeroObj, that takes a struct handle as its argument and is thus free of the aforementioned problem and can be propagated freely and not treated specially. It also, of course, retains the ZeroMap's selection property. There are almost no diffs for this change because of some other deficiencies in assertion and copy propagation, they are being/will be fixed separately.
Previously this codepath was reachable, but did not matter as the returned values were immediately discarded because of the conservative logic in VNApplySelectorsTypeCheck. This is still more or less the case, but let's just fix it properly.
0d5a6c0
to
c884372
Compare
@dotnet/jit-contrib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Previously, zero-initialized struct locals were given a special
$VNForZeroMap
, which had the nice property thatVNForMapSelect($VNForZeroMap, Field)
would always return zero of the appropriate type. However, the fact that this VN is not unique meant that it was dangerous to propagate it, e. g. through copies, which was hidden by the fact thatApplySelectorsTypeCheck
's logic is very conservative.This change introduces a new
VNFunc
to represent zeroed objects -VNF_ZeroObj
, that takes a struct handle as its argument and is thus free of the aforementioned problem and can be propagated freely and not treated specially. It also, of course, retains theZeroMap
's selection property.There are almost no diffs (
win-x64
,win-x86
,win-arm64
) for this change because of some other deficiencies in assertion and copy propagation, they are being/will be fixed separately, so the main point of this change is to contribute to #58312.Notes about the diffs
Some are exactly what we'd expect: dead code elimination due to better propagation of zeroes though struct copies:
Others are bizarre: CSEs created for the
IND
trees like the following:Here we have another case of type mismatch: VN thinks that the fields in the list are in fact struct fields:
This is "ok" because it only thinks that for the first field (subsequent ones get
PtrToLoc
withNotAField
VNs because the constant offsets do not have field sequences), and thelong
type of this "field" is fixed by the ABI, so this VN represents a properly unique value. It is definitely not by design though.Previously such
IND
s got$VN.ZeroMap
assigned to them (which is only supposed to be used for structs!) and did not get CSEd.Reproduction for this:
Part of #58312.