From 852405c649c1f26124974c97199053d6d8f2adab Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Fri, 5 Nov 2021 08:58:17 -0700 Subject: [PATCH] JIT: don't bother with GDV for an abstract class (#61191) Fixes #61190. --- src/coreclr/jit/importer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index d1c955fddb321..9dc10836d10a4 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -22230,6 +22230,17 @@ void Compiler::considerGuardedDevirtualization( return; } + uint32_t const likelyClassAttribs = info.compCompHnd->getClassAttribs(likelyClass); + + if ((likelyClassAttribs & CORINFO_FLG_ABSTRACT) != 0) + { + // We may see an abstract likely class, if we have a stale profile. + // No point guessing for this. + // + JITDUMP("Not guessing for class; abstract (stale profile)\n"); + return; + } + // Figure out which method will be called. // CORINFO_DEVIRTUALIZATION_INFO dvInfo; @@ -22253,7 +22264,6 @@ void Compiler::considerGuardedDevirtualization( // Add this as a potential candidate. // uint32_t const likelyMethodAttribs = info.compCompHnd->getMethodAttribs(likelyMethod); - uint32_t const likelyClassAttribs = info.compCompHnd->getClassAttribs(likelyClass); addGuardedDevirtualizationCandidate(call, likelyMethod, likelyClass, likelyMethodAttribs, likelyClassAttribs, likelihood); }