Encode calling convention in mangled function pointer representation (#81122)
authorTomáš Rylek <trylek@microsoft.com>
Tue, 31 Jan 2023 20:52:14 +0000 (21:52 +0100)
committerGitHub <noreply@github.com>
Tue, 31 Jan 2023 20:52:14 +0000 (21:52 +0100)
This fixes the recently introduced issue #81106 tracking Crossgen2
crash due to not being able to distinguish two function pointers
differing only by calling convention (one of the pointers is Static
and the other is Static | UnmanagedCallingConvention).

This change also removes the issues.targets exclusion for the
new function pointer test that Fan Yang had to add to unblock
merging in the test in the first place.

Thanks

Tomas

* Delete superfluous comment per Michal's PR feedback

src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs
src/tests/issues.targets

index 6e2751f..d5818b5 100644 (file)
@@ -290,9 +290,8 @@ namespace ILCompiler
                     mangledName = GetMangledTypeName(((PointerType)type).ParameterType) + NestMangledName("Pointer");
                     break;
                 case TypeFlags.FunctionPointer:
-                    // TODO: need to also encode calling convention (or all modopts?)
                     var fnPtrType = (FunctionPointerType)type;
-                    mangledName = "__FnPtr" + EnterNameScopeSequence;
+                    mangledName = "__FnPtr_" + ((int)fnPtrType.Signature.Flags).ToString("X2") + EnterNameScopeSequence;
                     mangledName += GetMangledTypeName(fnPtrType.Signature.ReturnType);
 
                     mangledName += EnterNameScopeSequence;
index adea692..5ea0e18 100644 (file)
         <ExcludeList Include="$(XunitTestBinBase)/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests/*">
             <Issue>https://github.com/dotnet/runtime/issues/81103</Issue>
         </ExcludeList>
-        <ExcludeList Include = "$(XunitTestBinBase)/Loader/classloader/Casting/Functionpointer/**">
-            <Issue>https://github.com/dotnet/runtime/issues/81106</Issue>
-        </ExcludeList>
     </ItemGroup>
 
     <!-- Crossgen2 x86 specific excludes -->