From 3b7439c46a13bb460229a51fbb5b799d60609cb4 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Mon, 25 Jul 2022 11:58:02 +0200 Subject: [PATCH 1/2] Ensure non generic method defs when using textual PGO The textual PGO format currently just describes methods by name and does not include signature information/generic instantiations. This means we may see various edge cases here.This particular case would hit asserts when the JIT started asking the runtime questions about this MD. --- src/coreclr/vm/pgo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/vm/pgo.cpp b/src/coreclr/vm/pgo.cpp index bce02bd2a315da..6d14ad8873d421 100644 --- a/src/coreclr/vm/pgo.cpp +++ b/src/coreclr/vm/pgo.cpp @@ -878,7 +878,10 @@ HRESULT PgoManager::getPgoInstrumentationResults(MethodDesc* pMD, BYTE** pAlloca if (!th.IsNull()) { MethodDesc* pMD = MemberLoader::FindMethodByName(th.GetMethodTable(), methodString.GetUTF8()); - newPtr = (INT_PTR)pMD; + if (pMD != nullptr && !pMD->IsGenericMethodDefinition()) + { + newPtr = (INT_PTR)pMD; + } } } } From b8a726757f0d43c4cd4ba3198a764b2ee59ac546 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 26 Jul 2022 13:33:24 +0200 Subject: [PATCH 2/2] Allow static profiles to contain static methods for non-delegate calls --- src/coreclr/jit/importer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 2420571e130aa2..6c832379867b63 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -22852,7 +22852,7 @@ void Compiler::considerGuardedDevirtualization(GenTreeCall* call, // resolve call above for class-based GDV. if ((likelyMethodAttribs & CORINFO_FLG_STATIC) != 0) { - assert(call->IsDelegateInvoke()); + assert((fgPgoSource != ICorJitInfo::PgoSource::Dynamic) || call->IsDelegateInvoke()); JITDUMP("Cannot currently handle devirtualizing static delegate calls, sorry\n"); return; }