Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
JIT: refine types when creating arg temps to improve devirtualization (
Browse files Browse the repository at this point in the history
…#13530)

The jit will refine the types of temps used to pass arguments to inlinees
when it creates the assignments to these temps.

Unfortunately this is too late to drive devirtualization in the body of
the inlinee, as thes assignments are created after the inlinee body is
imported.

So, add similar refinement logic to the place where the temps are first
created.

Closes #13520.
  • Loading branch information
AndyAyersMS committed Aug 23, 2017
1 parent f46134f commit 85c59f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22625,13 +22625,10 @@ GenTreePtr Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
impAssignTempGen(tmpNum, argNode, structHnd, (unsigned)CHECK_SPILL_NONE, &afterStmt, callILOffset,
block);

// If we know the argument's value can't be
// changed within the method body, try and improve
// the type of the temp.
if (argIsSingleDef && (argType == TYP_REF))
{
lvaUpdateClass(tmpNum, argNode);
}
// We used to refine the temp type here based on
// the actual arg, but we now do this up front, when
// creating the temp, over in impInlineFetchArg.
CLANG_FORMAT_COMMENT_ANCHOR;

#ifdef DEBUG
if (verbose)
Expand Down
17 changes: 14 additions & 3 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18165,11 +18165,22 @@ GenTreePtr Compiler::impInlineFetchArg(unsigned lclNum, InlArgInfo* inlArgInfo,

lvaTable[tmpNum].lvType = lclTyp;

// Copy over class handle for ref types. Note this may be
// further improved if it is a shared type and we know the exact context.
// For ref types, determine the type of the temp.
if (lclTyp == TYP_REF)
{
lvaSetClass(tmpNum, lclInfo.lclVerTypeInfo.GetClassHandleForObjRef());
if (!argCanBeModified)
{
// If the arg can't be modified in the method
// body, use the type of the value, if
// known. Otherwise, use the declared type.
lvaSetClass(tmpNum, argInfo.argNode, lclInfo.lclVerTypeInfo.GetClassHandleForObjRef());
}
else
{
// Arg might be modified, use the delcared type of
// the argument.
lvaSetClass(tmpNum, lclInfo.lclVerTypeInfo.GetClassHandleForObjRef());
}
}

assert(lvaTable[tmpNum].lvAddrExposed == 0);
Expand Down

0 comments on commit 85c59f9

Please sign in to comment.