From 608aa3e1f0fdc80994d1cf59389761e7831b5847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 17 Nov 2025 01:59:48 -0800 Subject: [PATCH] MethodEntrypointOrTentativeMethod should tolerate same entrypoints for different MethodDescs Ran into this as I was trying something with #121456. That PR introduces a situation where two MethodDescs could map to the same EntryPoint. We didn't previously have that since MethodEntrypointOrTentativeMethod doesn't support unboxing thunks (that do a similar trick). --- .../Compiler/DependencyAnalysis/NodeFactory.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs index 64a1741a6d0e88..68fb7ddfc6b2db 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs @@ -305,9 +305,9 @@ private void CreateNodeCaches() tentative.RealBody : (IMethodBodyNode)entrypoint); }); - _tentativeMethods = new NodeCache(method => + _tentativeMethods = new NodeCache(method => { - return new TentativeInstanceMethodNode((IMethodBodyNode)MethodEntrypoint(method)); + return new TentativeInstanceMethodNode(method); }); _unboxingStubs = new NodeCache(CreateUnboxingStubNode); @@ -1106,14 +1106,14 @@ public IMethodNode TentativeMethodEntrypoint(MethodDesc method, bool unboxingStu return _tentativeMethodEntrypoints.GetOrAdd(method); } - private NodeCache _tentativeMethods; + private NodeCache _tentativeMethods; public IMethodNode MethodEntrypointOrTentativeMethod(MethodDesc method, bool unboxingStub = false) { // We might be able to optimize the method body away if the owning type was never seen as allocated. if (method.NotCallableWithoutOwningEEType() && CompilationModuleGroup.AllowInstanceMethodOptimization(method)) { Debug.Assert(!unboxingStub); - return _tentativeMethods.GetOrAdd(method); + return _tentativeMethods.GetOrAdd((IMethodBodyNode)MethodEntrypoint(method, unboxingStub)); } return MethodEntrypoint(method, unboxingStub);