Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3726,13 +3726,13 @@ GenTree* Compiler::optAssertionProp_Call(ASSERT_VALARG_TP assertions, GenTreeCal
call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_CHKCASTANY) ||
call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_CHKCASTCLASS_SPECIAL))
{
GenTree* arg1 = gtArgEntryByArgNum(call, 1)->node;
GenTree* arg1 = gtArgEntryByArgNum(call, 1)->GetNode();
if (arg1->gtOper != GT_LCL_VAR)
{
return nullptr;
}

GenTree* arg2 = gtArgEntryByArgNum(call, 0)->node;
GenTree* arg2 = gtArgEntryByArgNum(call, 0)->GetNode();

unsigned index = optAssertionIsSubtype(arg1, arg2, assertions);
if (index != NO_ASSERTION_INDEX)
Expand Down
2 changes: 1 addition & 1 deletion src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7008,7 +7008,7 @@ void Compiler::compCallArgStats()

argTotalCalls++;

if (!call->gtCall.gtCallObjp)
if (call->AsCall()->gtCallThisArg == nullptr)
{
if (call->gtCall.gtCallType == CT_HELPER)
{
Expand Down
21 changes: 13 additions & 8 deletions src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1331,10 +1331,15 @@ struct FuncInfoDsc

struct fgArgTabEntry
{
GenTree* node; // Initially points to `use`'s node, but if the argument is replaced with an GT_ASG or
// placeholder it will point at the actual argument node in the gtCallLateArgs list.
GenTreeCall::Use* use; // Points at the GenTreeCall::Use in the gtCallArgs for this argument
// or nullptr for the `this` argument which does not have a corresponding GenTreeCall::Use.
GenTreeCall::Use* use; // Points to the argument's GenTreeCall::Use in gtCallArgs or gtCallThisArg.
GenTreeCall::Use* lateUse; // Points to the argument's GenTreeCall::Use in gtCallLateArgs, if any.

// Get the node that coresponds to this argument entry.
// This is the "real" node and not a placeholder or setup node.
GenTree* GetNode() const
{
return lateUse == nullptr ? use->GetNode() : lateUse->GetNode();
}

unsigned argNum; // The original argument number, also specifies the required argument evaluation order from the IL

Expand Down Expand Up @@ -1700,6 +1705,7 @@ struct fgArgTabEntry
//
void checkIsStruct()
{
GenTree* node = GetNode();
if (isStruct)
{
if (!varTypeIsStruct(node) && !node->OperIs(GT_FIELD_LIST))
Expand Down Expand Up @@ -1919,7 +1925,7 @@ class fgArgInfo
// Caller must ensure that this index is a valid arg index.
GenTree* GetArgNode(unsigned argIndex)
{
return GetArgEntry(argIndex)->node;
return GetArgEntry(argIndex)->GetNode();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a random thing:
in GenTreeCall::Use::SetNode we check that assert(node != nullptr);, so as I understand our contract is that if we have a Use then we have a not-null node, but we don't check that in the Use constructor, so we can call GenTreeCall::Use(nullptr) and do bad things.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I need to check this. AFAIR I didn't add an assert in the Use constructor due to some funny code in fgArgInfo::fgArgInfo that was manufacturing uses out of thin air. That code is gone now so perhaps I can add an assert.

}

void Dump(Compiler* compiler);
Expand Down Expand Up @@ -2596,7 +2602,6 @@ class Compiler
static fgArgTabEntry* gtArgEntryByNode(GenTreeCall* call, GenTree* node);
fgArgTabEntry* gtArgEntryByLateArgIndex(GenTreeCall* call, unsigned lateArgInx);
static GenTree* gtArgNodeByLateArgInx(GenTreeCall* call, unsigned lateArgInx);
bool gtArgIsThisPtr(fgArgTabEntry* argEntry);

GenTree* gtNewAssignNode(GenTree* dst, GenTree* src);

Expand Down Expand Up @@ -10151,9 +10156,9 @@ class GenTreeVisitor
{
GenTreeCall* const call = node->AsCall();

if (call->gtCallObjp != nullptr)
if (call->gtCallThisArg != nullptr)
{
result = WalkTree(&call->gtCallObjp, call);
result = WalkTree(&call->gtCallThisArg->NodeRef(), call);
if (result == fgWalkResult::WALK_ABORT)
{
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4412,7 +4412,7 @@ void GenTree::VisitOperands(TVisitor visitor)
case GT_CALL:
{
GenTreeCall* const call = this->AsCall();
if ((call->gtCallObjp != nullptr) && (visitor(call->gtCallObjp) == VisitResult::Abort))
if ((call->gtCallThisArg != nullptr) && (visitor(call->gtCallThisArg->GetNode()) == VisitResult::Abort))
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/jit/earlyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ GenTree* Compiler::getArrayLengthFromAllocation(GenTree* tree)
call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_NEWARR_1_ALIGN8))
{
// This is an array allocation site. Grab the array length node.
return gtArgEntryByArgNum(call, 1)->node;
return gtArgEntryByArgNum(call, 1)->GetNode();
}
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ GenTree* Compiler::getObjectHandleNodeFromAllocation(GenTree* tree)
{
// This is an object allocation site. Return the runtime type handle node.
fgArgTabEntry* argTabEntry = gtArgEntryByArgNum(call, 0);
return argTabEntry->node;
return argTabEntry->GetNode();
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7461,7 +7461,7 @@ GenTree* Compiler::fgOptimizeDelegateConstructor(GenTreeCall* call,
{
JITDUMP("optimized\n");

GenTree* thisPointer = call->gtCallObjp;
GenTree* thisPointer = call->gtCallThisArg->GetNode();
GenTree* targetObjPointers = call->gtCallArgs->GetNode();
GenTreeCall::Use* helperArgs = nullptr;
CORINFO_LOOKUP pLookup;
Expand Down Expand Up @@ -7495,7 +7495,7 @@ GenTree* Compiler::fgOptimizeDelegateConstructor(GenTreeCall* call,
{
JITDUMP("optimized\n");

GenTree* thisPointer = call->gtCallObjp;
GenTree* thisPointer = call->gtCallThisArg->GetNode();
GenTree* targetObjPointers = call->gtCallArgs->GetNode();
GenTreeCall::Use* helperArgs = gtNewCallArgs(thisPointer, targetObjPointers);

Expand Down Expand Up @@ -18781,9 +18781,9 @@ void Compiler::fgSetTreeSeqHelper(GenTree* tree, bool isLIR)
case GT_CALL:

/* We'll evaluate the 'this' argument value first */
if (tree->gtCall.gtCallObjp)
if (tree->AsCall()->gtCallThisArg != nullptr)
{
fgSetTreeSeqHelper(tree->gtCall.gtCallObjp, isLIR);
fgSetTreeSeqHelper(tree->AsCall()->gtCallThisArg->GetNode(), isLIR);
}

for (GenTreeCall::Use& use : tree->AsCall()->Args())
Expand Down Expand Up @@ -21320,12 +21320,12 @@ void Compiler::fgDebugCheckFlags(GenTree* tree)

call = tree->AsCall();

if (call->gtCallObjp)
if (call->gtCallThisArg != nullptr)
{
fgDebugCheckFlags(call->gtCallObjp);
chkFlags |= (call->gtCallObjp->gtFlags & GTF_SIDE_EFFECT);
fgDebugCheckFlags(call->gtCallThisArg->GetNode());
chkFlags |= (call->gtCallThisArg->GetNode()->gtFlags & GTF_SIDE_EFFECT);

if (call->gtCallObjp->gtFlags & GTF_ASG)
if ((call->gtCallThisArg->GetNode()->gtFlags & GTF_ASG) != 0)
{
treeFlags |= GTF_ASG;
}
Expand Down
Loading