From 864c2f5d0bb7bfc5e16ca1d427a0d6e987526138 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Thu, 12 Dec 2024 16:52:52 -0800 Subject: [PATCH 1/2] JIT: capture class types when spilling a GDV arg If we need to spill ref type args for a GDV, try to annotate the spilled locals with type information. --- src/coreclr/jit/indirectcalltransformer.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/indirectcalltransformer.cpp b/src/coreclr/jit/indirectcalltransformer.cpp index 9fbac3b55a46ee..8cf24136de158e 100644 --- a/src/coreclr/jit/indirectcalltransformer.cpp +++ b/src/coreclr/jit/indirectcalltransformer.cpp @@ -754,8 +754,21 @@ class IndirectCallTransformer // void SpillArgToTempBeforeGuard(CallArg* arg) { - unsigned tmpNum = compiler->lvaGrabTemp(true DEBUGARG("guarded devirt arg temp")); - GenTree* store = compiler->gtNewTempStore(tmpNum, arg->GetNode()); + unsigned tmpNum = compiler->lvaGrabTemp(true DEBUGARG("guarded devirt arg temp")); + GenTree* const argNode = arg->GetNode(); + GenTree* store = compiler->gtNewTempStore(tmpNum, argNode); + + if (argNode->TypeGet() == TYP_REF) + { + bool isExact = false; + bool isNonNull = false; + CORINFO_CLASS_HANDLE cls = compiler->gtGetClassHandle(argNode, &isExact, &isNonNull); + if (cls != NO_CLASS_HANDLE) + { + compiler->lvaSetClass(tmpNum, cls, isExact); + } + } + Statement* storeStmt = compiler->fgNewStmtFromTree(store, stmt->GetDebugInfo()); compiler->fgInsertStmtAtEnd(checkBlock, storeStmt); From 7d1b6355e3adebcd267f7cd03cfa1c92f3c20475 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Fri, 13 Dec 2024 08:17:31 -0800 Subject: [PATCH 2/2] Update src/coreclr/jit/indirectcalltransformer.cpp Co-authored-by: Jakob Botsch Nielsen --- src/coreclr/jit/indirectcalltransformer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/indirectcalltransformer.cpp b/src/coreclr/jit/indirectcalltransformer.cpp index 8cf24136de158e..f2149f62546b87 100644 --- a/src/coreclr/jit/indirectcalltransformer.cpp +++ b/src/coreclr/jit/indirectcalltransformer.cpp @@ -758,7 +758,7 @@ class IndirectCallTransformer GenTree* const argNode = arg->GetNode(); GenTree* store = compiler->gtNewTempStore(tmpNum, argNode); - if (argNode->TypeGet() == TYP_REF) + if (argNode->TypeIs(TYP_REF)) { bool isExact = false; bool isNonNull = false;