You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
ILLink substitute BitConverter.IsLittleEndian as true constant #83169
So while it seems that ILLink did touch this method (thanks to #37615) it seems that it could do a better job here by replacing ldsfld bool System.BitConverter::IsLittleEndian with just ldc.i4.1, etc.
This doesn't let JIT to inline this small (in fact) method, because JIT doesn't resolve ldsfld tokens during IL prescan and it doesn't know that it's a special IsLittleEndian field that is always a constant) - it can be found in e.g. GetIndexOfFirstNonAsciiChar_Intrinsified
Activity
ghost added
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
If it's the access to the substituted field (and not a propagated constant) I think it should be OK to remove the ldsfld completely. But I haven't debugged the linker to tell exactly why it's keeping the instruction - it could be just general "conservative" approach.
Is linker keeping the ldsfld around to preserve the cctor trigger side effect?
Correct, we didn't put any effort yet to teach linker how to trim static constructors bodies and for that reason we also keep anything that could static ctor even when applying the substitutions.
Is linker keeping the ldsfld around to preserve the cctor trigger side effect?
Correct, we didn't put any effort yet to teach linker how to trim static constructors bodies and for that reason we also keep anything that could static ctor even when applying the substitutions.
It seems that even if I remove static constructor from BitConverter (IsLittleEndian = true; is not needed since that field is an intrinsic for CoreCLR/Crossgen/NAOT) - it still doesn't remove the field
Activity
jkotas commentedon Mar 9, 2023
Is linker keeping the
ldsfldaround to preserve the cctor trigger side effect? Preserving these side-effects is important for some substitutions.jkotas commentedon Mar 9, 2023
Should the JIT start doing that in Tier1 or AOT modes to give the right treatment to initialized readonly fields?
vitek-karas commentedon Mar 9, 2023
If it's the access to the substituted field (and not a propagated constant) I think it should be OK to remove the
ldsfldcompletely. But I haven't debugged the linker to tell exactly why it's keeping the instruction - it could be just general "conservative" approach.EgorBo commentedon Mar 9, 2023
I'll take a look
marek-safar commentedon Mar 9, 2023
Correct, we didn't put any effort yet to teach linker how to trim static constructors bodies and for that reason we also keep anything that could static ctor even when applying the substitutions.
EgorBo commentedon Mar 9, 2023
It seems that even if I remove static constructor from
BitConverter(IsLittleEndian = true; is not needed since that field is an intrinsic for CoreCLR/Crossgen/NAOT) - it still doesn't remove the fieldEgorBo commentedon Mar 9, 2023
Ah, the lambda in https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/BitConverter.cs#L672 still keeps it 😞 - presumably, can be replaced with string.FastAllocate