diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index bf9d81921021b..2420571e130aa 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -11052,7 +11052,7 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op, return op; } - if (op->gtOper == GT_CALL) + if (op->IsCall() && (op->AsCall()->GetUnmanagedCallConv() == unmgdCallConv)) { return op; } diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_72265/Runtime_72265.cs b/src/tests/JIT/Regression/JitBlue/Runtime_72265/Runtime_72265.cs new file mode 100644 index 0000000000000..7bc0b254f9c86 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_72265/Runtime_72265.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +unsafe class Runtime_72265 +{ + private static int Main() + { + var unmanaged = ((delegate* unmanaged)&GetStructUnmanaged)(); + var managed = GetStructManaged(); + + return !unmanaged.Equals(managed) ? 101 : 100; + } + + [UnmanagedCallersOnly] + private static StructWithIndex GetStructUnmanaged() + { + return GetStructManaged(); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static StructWithIndex GetStructManaged() => new StructWithIndex { Index = 10, Value = 11 }; + + struct StructWithIndex + { + public int Index; + public int Value; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_72265/Runtime_72265.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_72265/Runtime_72265.csproj new file mode 100644 index 0000000000000..cf94135633b19 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_72265/Runtime_72265.csproj @@ -0,0 +1,10 @@ + + + Exe + True + true + + + + + \ No newline at end of file diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 038df8e392e20..a284d2bff7084 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -1957,6 +1957,9 @@ needs triage + + https://github.com/dotnet/runtime/issues/72016 + needs triage