Skip to content

Commit d39490d

Browse files
[RyuJit] Mark some well-known indirs with some flags (#118289)
1 parent 3230699 commit d39490d

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

src/coreclr/jit/assertionprop.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,7 +4169,7 @@ AssertionIndex Compiler::optGlobalAssertionIsEqualOrNotEqual(ASSERT_VALARG_TP as
41694169

41704170
// Look for matching exact type assertions based on vtable accesses. E.g.:
41714171
//
4172-
// op1: VNF_InvariantLoad(myObj) or in other words: a vtable access
4172+
// op1: VNF_InvariantNonNullLoad(myObj) or in other words: a vtable access
41734173
// op2: 'MyType' class handle
41744174
// Assertion: 'myObj's type is exactly MyType
41754175
//
@@ -4178,7 +4178,7 @@ AssertionIndex Compiler::optGlobalAssertionIsEqualOrNotEqual(ASSERT_VALARG_TP as
41784178
{
41794179
VNFuncApp funcApp;
41804180
if (vnStore->GetVNFunc(vnStore->VNConservativeNormalValue(op1->gtVNPair), &funcApp) &&
4181-
(funcApp.m_func == VNF_InvariantLoad) && (curAssertion->op1.vn == funcApp.m_args[0]))
4181+
(funcApp.m_func == VNF_InvariantNonNullLoad) && (curAssertion->op1.vn == funcApp.m_args[0]))
41824182
{
41834183
return assertionIndex;
41844184
}

src/coreclr/jit/compiler.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,8 +1935,9 @@ inline GenTreeCast* Compiler::gtNewCastNodeL(var_types typ, GenTree* op1, bool f
19351935

19361936
inline GenTreeIndir* Compiler::gtNewMethodTableLookup(GenTree* object, bool onStack)
19371937
{
1938+
static_assert_no_msg(VPTR_OFFS == 0);
19381939
assert(onStack || object->TypeIs(TYP_REF));
1939-
GenTreeIndir* result = gtNewIndir(TYP_I_IMPL, object, GTF_IND_INVARIANT);
1940+
GenTreeIndir* result = gtNewIndir(TYP_I_IMPL, object, GTF_IND_INVARIANT | GTF_IND_NONNULL);
19401941
return result;
19411942
}
19421943

src/coreclr/jit/indirectcalltransformer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,10 @@ class IndirectCallTransformer
415415
{
416416
elseBlock = CreateAndInsertBasicBlock(BBJ_ALWAYS, thenBlock, currBlock);
417417

418-
GenTree* fixedFptrAddress = GetFixedFptrAddress();
419-
GenTree* actualCallAddress = compiler->gtNewIndir(pointerType, fixedFptrAddress);
420-
GenTree* hiddenArgument = GetHiddenArgument(fixedFptrAddress);
418+
GenTree* fixedFptrAddress = GetFixedFptrAddress();
419+
GenTree* actualCallAddress =
420+
compiler->gtNewIndir(pointerType, fixedFptrAddress, GTF_IND_NONFAULTING | GTF_IND_INVARIANT);
421+
GenTree* hiddenArgument = GetHiddenArgument(fixedFptrAddress);
421422

422423
Statement* fatStmt = CreateFatCallStmt(actualCallAddress, hiddenArgument);
423424
compiler->fgInsertStmtAtEnd(elseBlock, fatStmt);
@@ -448,7 +449,8 @@ class IndirectCallTransformer
448449
GenTree* fixedFptrAddressCopy = compiler->gtCloneExpr(fixedFptrAddress);
449450
GenTree* wordSize = new (compiler, GT_CNS_INT) GenTreeIntCon(TYP_I_IMPL, genTypeSize(TYP_I_IMPL));
450451
GenTree* hiddenArgumentPtr = compiler->gtNewOperNode(GT_ADD, pointerType, fixedFptrAddressCopy, wordSize);
451-
return compiler->gtNewIndir(fixedFptrAddressCopy->TypeGet(), hiddenArgumentPtr);
452+
return compiler->gtNewIndir(fixedFptrAddressCopy->TypeGet(), hiddenArgumentPtr,
453+
GTF_IND_NONFAULTING | GTF_IND_INVARIANT);
452454
}
453455

454456
//------------------------------------------------------------------------

src/coreclr/jit/loopcloning.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ GenTree* LC_Ident::ToGenTree(Compiler* comp, BasicBlock* bb)
177177
case IndirOfLocal:
178178
{
179179
GenTree* addr = comp->gtNewLclvNode(lclNum, TYP_REF);
180-
if (indirOffs != 0)
180+
if (indirOffs == 0)
181181
{
182-
addr = comp->gtNewOperNode(GT_ADD, TYP_BYREF, addr,
183-
comp->gtNewIconNode(static_cast<ssize_t>(indirOffs), TYP_I_IMPL));
182+
return comp->gtNewMethodTableLookup(addr);
184183
}
185184

185+
addr = comp->gtNewOperNode(GT_ADD, TYP_BYREF, addr,
186+
comp->gtNewIconNode(static_cast<ssize_t>(indirOffs), TYP_I_IMPL));
186187
GenTree* const indir = comp->gtNewIndir(TYP_I_IMPL, addr, GTF_IND_INVARIANT);
187188
return indir;
188189
}

src/coreclr/jit/morph.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6608,8 +6608,7 @@ GenTree* Compiler::fgExpandVirtualVtableCallTarget(GenTreeCall* call)
66086608
&isRelative);
66096609

66106610
// Dereference the this pointer to obtain the method table, it is called vtab below
6611-
assert(VPTR_OFFS == 0); // We have to add this value to the thisPtr to get the methodTable
6612-
GenTree* vtab = gtNewIndir(TYP_I_IMPL, thisPtr, GTF_IND_INVARIANT);
6611+
GenTree* vtab = gtNewMethodTableLookup(thisPtr);
66136612

66146613
if (fgGlobalMorph)
66156614
{

0 commit comments

Comments
 (0)