-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT: Inlining may produce incorrectly byref-typed SUB trees #84291
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue DetailsSee #82166 (comment): STMT00051 ( 0x000[E-] ... ??? ) <- INL02 @ 0x000[E-] <- INLRT @ 0x0A1[E-]
[000177] -A--------- ▌ ASG long
[000176] D------N--- ├──▌ LCL_VAR long V10 tmp1
[000175] ----------- └──▌ SUB byref
[000173] ----------- ├──▌ FIELD_ADDR byref SequentialLayoutMinPacking`1[ushort]:_byte
[000174] ----------- │ └──▌ LCL_VAR_ADDR byref V04 loc1
[000172] ----------- └──▌ LCL_VAR_ADDR long V04 loc1
|
This might not be too hard to fix; the actual signature types are available in the |
Solves the particular problematic case from dotnet#84291.
Solves the particular problematic case from #84291.
Moving to 9.0 (will see if I have time to land this in 8.0 as the best effort) |
@jakobbotsch I can't reproduce it on Main it seems,
|
I was playing with this repro: using System.Numerics;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.InteropServices;
public class Program
{
public static void Main()
{
new SequentialLayoutMinPacking<ushort>().OffsetOfByte();
new SequentialLayoutMinPacking<ushort>().OffsetOfValue();
}
internal static int OffsetOf<T, U>(ref T origin, ref U target)
{
return Unsafe.ByteOffset(ref origin, ref Unsafe.As<U, T>(ref target)).ToInt32();
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct SequentialLayoutMinPacking<T>
{
public byte _byte;
public T _value;
public int Size => Unsafe.SizeOf<SequentialLayoutMinPacking<T>>();
[MethodImpl(MethodImplOptions.NoInlining)]
public int OffsetOfByte() => Program.OffsetOf(ref this, ref _byte);
[MethodImpl(MethodImplOptions.NoInlining)]
public int OffsetOfValue() => Program.OffsetOf(ref this, ref _value);
} |
Spoke with @jakobbotsch offline, it seems that #89324 has fixed it and it's no longer possible to reproduce it in C#/Unsafe, only with raw IL. So moving to future for now. |
See #82166 (comment):
impGetByRefResultType
bases its result on the type of operands, yet the inliner can directly substitute argument trees in some cases causing this to not really work out in the expected way.The text was updated successfully, but these errors were encountered: