Fix a couple of issues when using textual PGO input (#72773)
authorJakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
Wed, 27 Jul 2022 14:50:11 +0000 (16:50 +0200)
committerGitHub <noreply@github.com>
Wed, 27 Jul 2022 14:50:11 +0000 (16:50 +0200)
* Ensure non generic method defs when using textual PGO

* Allow static profiles to contain static methods for non-delegate calls

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. These particular cases would hit asserts.

src/coreclr/jit/importer.cpp
src/coreclr/vm/pgo.cpp

index 61d3977..e14f500 100644 (file)
@@ -22801,7 +22801,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;
         }
index bce02bd..6d14ad8 100644 (file)
@@ -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;
+                                                        }
                                                     }
                                                 }
                                             }