Skip to content

Commit f10cdda

Browse files
authored
Remove GTF_LATE_ARG (dotnet#68617)
This serves no purpose anymore after the call args refactoring and removing stores as call operands in LIR.
1 parent 6256adf commit f10cdda

File tree

11 files changed

+13
-125
lines changed

11 files changed

+13
-125
lines changed

docs/design/coreclr/jit/jit-call-morphing.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ For arguments that are marked as needing a temp:
131131

132132
1. We create an assignment using `gtNewTempAssign`. This assignment replaces
133133
the original argument in the early argument list. After we create the assignment
134-
the argument is marked with `m_isTmp = true`. The new assignment is marked with the
135-
`GTF_LATE_ARG` flag.
134+
the argument is marked with `m_isTmp = true`.
136135
2. Arguments that are already marked with `m_isTmp` are treated similarly as
137136
above except we don't create an assignment for them.
138137
3. A `TYP_STRUCT` argument passed by value will have `m_isTmp` set to true

src/coreclr/jit/codegenxarch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5380,7 +5380,7 @@ void CodeGen::genCall(GenTreeCall* call)
53805380
for (CallArg& arg : call->gtArgs.EarlyArgs())
53815381
{
53825382
GenTree* argNode = arg.GetEarlyNode();
5383-
if (argNode->OperIs(GT_PUTARG_STK) && ((argNode->gtFlags & GTF_LATE_ARG) == 0))
5383+
if (argNode->OperIs(GT_PUTARG_STK) && (arg.GetLateNode() == nullptr))
53845384
{
53855385
GenTree* source = argNode->AsPutArgStk()->gtGetOp1();
53865386
unsigned size = argNode->AsPutArgStk()->GetStackByteSize();

src/coreclr/jit/compiler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9681,10 +9681,6 @@ void cTreeFlags(Compiler* comp, GenTree* tree)
96819681
{
96829682
chars += printf("[SMALL_UNSIGNED]");
96839683
}
9684-
if (tree->gtFlags & GTF_LATE_ARG)
9685-
{
9686-
chars += printf("[SMALL_LATE_ARG]");
9687-
}
96889684
if (tree->gtFlags & GTF_SPILL)
96899685
{
96909686
chars += printf("[SPILL]");

src/coreclr/jit/gentree.cpp

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,42 +2109,6 @@ bool GenTreeCall::IsHelperCall(Compiler* compiler, unsigned helper) const
21092109
return IsHelperCall(compiler->eeFindHelper(helper));
21102110
}
21112111

2112-
//------------------------------------------------------------------------
2113-
// GenTreeCall::ReplaceCallOperand:
2114-
// Replaces a given operand to a call node and updates the call
2115-
// argument table if necessary.
2116-
//
2117-
// Arguments:
2118-
// useEdge - the use edge that points to the operand to be replaced.
2119-
// replacement - the replacement node.
2120-
//
2121-
void GenTreeCall::ReplaceCallOperand(GenTree** useEdge, GenTree* replacement)
2122-
{
2123-
assert(useEdge != nullptr);
2124-
assert(replacement != nullptr);
2125-
assert(TryGetUse(*useEdge, &useEdge));
2126-
2127-
GenTree* originalOperand = *useEdge;
2128-
*useEdge = replacement;
2129-
2130-
const bool isArgument =
2131-
(replacement != gtControlExpr) &&
2132-
((gtCallType != CT_INDIRECT) || ((replacement != gtCallCookie) && (replacement != gtCallAddr)));
2133-
2134-
if (isArgument)
2135-
{
2136-
if ((originalOperand->gtFlags & GTF_LATE_ARG) != 0)
2137-
{
2138-
replacement->gtFlags |= GTF_LATE_ARG;
2139-
}
2140-
else
2141-
{
2142-
assert((replacement->gtFlags & GTF_LATE_ARG) == 0);
2143-
assert(gtArgs.FindByNode(replacement)->GetNode() == replacement);
2144-
}
2145-
}
2146-
}
2147-
21482112
//--------------------------------------------------------------------------
21492113
// Equals: Check if 2 CALL nodes are equal.
21502114
//
@@ -6140,15 +6104,7 @@ void GenTree::ReplaceOperand(GenTree** useEdge, GenTree* replacement)
61406104
assert(useEdge != nullptr);
61416105
assert(replacement != nullptr);
61426106
assert(TryGetUse(*useEdge, &useEdge));
6143-
6144-
if (OperGet() == GT_CALL)
6145-
{
6146-
AsCall()->ReplaceCallOperand(useEdge, replacement);
6147-
}
6148-
else
6149-
{
6150-
*useEdge = replacement;
6151-
}
6107+
*useEdge = replacement;
61526108
}
61536109

61546110
//------------------------------------------------------------------------
@@ -9686,7 +9642,7 @@ void GenTree::SetIndirExceptionFlags(Compiler* comp)
96869642

96879643
/* static */ int GenTree::gtDispFlags(GenTreeFlags flags, GenTreeDebugFlags debugFlags)
96889644
{
9689-
int charsDisplayed = 11; // 11 is the "baseline" number of flag characters displayed
9645+
int charsDisplayed = 10; // the "baseline" number of flag characters displayed
96909646

96919647
printf("%c", (flags & GTF_ASG) ? 'A' : (IsContained(flags) ? 'c' : '-'));
96929648
printf("%c", (flags & GTF_CALL) ? 'C' : '-');
@@ -9703,7 +9659,6 @@ void GenTree::SetIndirExceptionFlags(Compiler* comp)
97039659
printf("%c", (flags & GTF_SET_FLAGS) ? 'S' : '-');
97049660
++charsDisplayed;
97059661
#endif
9706-
printf("%c", (flags & GTF_LATE_ARG) ? 'L' : '-');
97079662
printf("%c", (flags & GTF_SPILLED) ? 'z' : (flags & GTF_SPILL) ? 'Z' : '-');
97089663

97099664
return charsDisplayed;
@@ -15677,11 +15632,6 @@ void Compiler::gtExtractSideEffList(GenTree* expr,
1567715632

1567815633
void PushSideEffects(GenTree* node)
1567915634
{
15680-
// The extracted side effect will no longer be an argument, so unmark it.
15681-
// This is safe to do because the side effects will be visited in pre-order,
15682-
// aborting as soon as any tree is extracted. Thus if an argument for a call
15683-
// is being extracted, it is guaranteed that the call itself will not be.
15684-
node->gtFlags &= ~GTF_LATE_ARG;
1568515635
m_sideEffects.Push(node);
1568615636
}
1568715637
};

src/coreclr/jit/gentree.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ enum GenTreeFlags : unsigned int
405405

406406
GTF_UNSIGNED = 0x00008000, // With GT_CAST: the source operand is an unsigned type
407407
// With operators: the specified node is an unsigned operator
408-
GTF_LATE_ARG = 0x00010000, // The specified node is evaluated to a temp in the arg list, and this temp is added to gtCallLateArgs.
409408
GTF_SPILL = 0x00020000, // Needs to be spilled here
410409

411410
// The extra flag GTF_IS_IN_CSE is used to tell the consumer of the side effect flags
@@ -5161,8 +5160,6 @@ struct GenTreeCall final : public GenTree
51615160

51625161
bool IsHelperCall(Compiler* compiler, unsigned helper) const;
51635162

5164-
void ReplaceCallOperand(GenTree** operandUseEdge, GenTree* replacement);
5165-
51665163
bool AreArgsComplete() const;
51675164

51685165
CorInfoCallConvExtension GetUnmanagedCallConv() const

src/coreclr/jit/liveness.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,8 +2193,6 @@ bool Compiler::fgTryRemoveNonLocal(GenTree* node, LIR::Range* blockRange)
21932193
void Compiler::fgRemoveDeadStoreLIR(GenTree* store, BasicBlock* block)
21942194
{
21952195
LIR::Range& blockRange = LIR::AsRange(block);
2196-
2197-
assert((store->gtFlags & GTF_LATE_ARG) == 0);
21982196
blockRange.Remove(store);
21992197
assert(!opts.MinOpts());
22002198
fgStmtRemoved = true;

src/coreclr/jit/lower.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,10 +1314,6 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, CallArg* callArg,
13141314
DISPNODE(putArg);
13151315
JITDUMP("\n");
13161316

1317-
if (arg->gtFlags & GTF_LATE_ARG)
1318-
{
1319-
putArg->gtFlags |= GTF_LATE_ARG;
1320-
}
13211317
return putArg;
13221318
}
13231319

@@ -3537,9 +3533,7 @@ void Lowering::LowerStoreLocCommon(GenTreeLclVarCommon* lclStore)
35373533
// Create the assignment node.
35383534
lclStore->ChangeOper(GT_STORE_OBJ);
35393535
GenTreeBlk* objStore = lclStore->AsObj();
3540-
// Only the GTF_LATE_ARG flag (if present) is preserved.
3541-
objStore->gtFlags &= GTF_LATE_ARG;
3542-
objStore->gtFlags |= GTF_ASG | GTF_IND_NONFAULTING | GTF_IND_TGT_NOT_HEAP;
3536+
objStore->gtFlags = GTF_ASG | GTF_IND_NONFAULTING | GTF_IND_TGT_NOT_HEAP;
35433537
#ifndef JIT32_GCENCODER
35443538
objStore->gtBlkOpGcUnsafe = false;
35453539
#endif

src/coreclr/jit/lsraarmarch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ int LinearScan::BuildCall(GenTreeCall* call)
343343
{
344344
GenTree* argNode = arg.GetEarlyNode();
345345

346-
// Skip arguments that have been moved to the Late Arg list
347-
if ((argNode->gtFlags & GTF_LATE_ARG) == 0)
346+
// Skip arguments that have been moved to the late list
347+
if (arg.GetLateNode() == nullptr)
348348
{
349-
// PUTARG_SPLIT nodes must be in the gtCallLateArgs list, since they
349+
// PUTARG_SPLIT nodes must be in the late list, since they
350350
// define registers used by the call.
351351
assert(argNode->OperGet() != GT_PUTARG_SPLIT);
352352
if (argNode->gtOper == GT_PUTARG_STK)

src/coreclr/jit/morph.cpp

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,9 +1581,6 @@ void CallArgs::EvalArgsToTemps(Compiler* comp, GenTreeCall* call)
15811581
{
15821582
// Create a copy of the temp to go into the late argument list
15831583
defArg = MakeTmpArgNode(comp, &arg);
1584-
1585-
// mark the original node as a late argument
1586-
argx->gtFlags |= GTF_LATE_ARG;
15871584
}
15881585
else
15891586
{
@@ -1711,9 +1708,6 @@ void CallArgs::EvalArgsToTemps(Compiler* comp, GenTreeCall* call)
17111708
#endif // TARGET_ARM
17121709
}
17131710

1714-
/* mark the assignment as a late argument */
1715-
setupArg->gtFlags |= GTF_LATE_ARG;
1716-
17171711
#ifdef DEBUG
17181712
if (comp->verbose)
17191713
{
@@ -3641,8 +3635,7 @@ void Compiler::fgMorphMultiregStructArgs(GenTreeCall* call)
36413635

36423636
for (CallArg& arg : call->gtArgs.Args())
36433637
{
3644-
bool isLateArg = arg.GetLateNode() != nullptr;
3645-
GenTree* argx = arg.GetNode();
3638+
GenTree*& argx = arg.GetLateNode() != nullptr ? arg.LateNodeRef() : arg.EarlyNodeRef();
36463639

36473640
if (!arg.AbiInfo.IsStruct)
36483641
{
@@ -3685,19 +3678,7 @@ void Compiler::fgMorphMultiregStructArgs(GenTreeCall* call)
36853678
}
36863679

36873680
GenTree* newArgx = fgMorphMultiregStructArg(&arg);
3688-
3689-
// Did we replace 'argx' with a new tree?
3690-
if (newArgx != argx)
3691-
{
3692-
if (isLateArg)
3693-
{
3694-
arg.SetLateNode(newArgx);
3695-
}
3696-
else
3697-
{
3698-
arg.SetEarlyNode(newArgx);
3699-
}
3700-
}
3681+
argx = newArgx;
37013682
}
37023683
}
37033684
}
@@ -8254,7 +8235,7 @@ void Compiler::fgMorphRecursiveFastTailCallIntoLoop(BasicBlock* block, GenTreeCa
82548235
for (CallArg& arg : recursiveTailCall->gtArgs.EarlyArgs())
82558236
{
82568237
GenTree* earlyArg = arg.GetEarlyNode();
8257-
if ((earlyArg->gtFlags & GTF_LATE_ARG) != 0)
8238+
if (arg.GetLateNode() != nullptr)
82588239
{
82598240
// This is a setup node so we need to hoist it.
82608241
Statement* earlyArgStmt = gtNewStmt(earlyArg, callDI);
@@ -8678,8 +8659,6 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call)
86788659
assert(argNode != arr);
86798660
assert(argNode != index);
86808661

8681-
argNode->gtFlags &= ~GTF_LATE_ARG;
8682-
86838662
GenTree* op1 = argSetup;
86848663
if (op1 == nullptr)
86858664
{
@@ -12352,7 +12331,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
1235212331
}
1235312332
else
1235412333
{
12355-
op2->gtFlags |= (tree->gtFlags & (GTF_DONT_CSE | GTF_LATE_ARG));
12334+
op2->gtFlags |= (tree->gtFlags & GTF_DONT_CSE);
1235612335
DEBUG_DESTROY_NODE(tree);
1235712336
DEBUG_DESTROY_NODE(op1);
1235812337
return op2;
@@ -12362,7 +12341,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
1236212341
// comma throw, in which case we want the top-level morphing loop to recognize it.
1236312342
if (op2->IsNothingNode() && op1->TypeIs(TYP_VOID) && !fgIsCommaThrow(tree))
1236412343
{
12365-
op1->gtFlags |= (tree->gtFlags & (GTF_DONT_CSE | GTF_LATE_ARG));
12344+
op1->gtFlags |= (tree->gtFlags & GTF_DONT_CSE);
1236612345
DEBUG_DESTROY_NODE(tree);
1236712346
DEBUG_DESTROY_NODE(op2);
1236812347
return op1;

src/coreclr/jit/morphblock.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class MorphInitBlockHelper
4646
GenTree* m_dstAddr = nullptr;
4747
ssize_t m_dstAddOff = 0;
4848

49-
#if defined(DEBUG)
50-
bool m_isLateArg = false;
51-
#endif // DEBUG
52-
5349
enum class BlockTransformation
5450
{
5551
Undefined,
@@ -129,8 +125,6 @@ GenTree* MorphInitBlockHelper::Morph()
129125
PrepareDst();
130126
PrepareSrc();
131127

132-
INDEBUG(m_isLateArg = (m_asg->gtFlags & GTF_LATE_ARG) != 0);
133-
134128
TrySpecialCases();
135129

136130
if (m_transformationDecision == BlockTransformation::Undefined)
@@ -156,17 +150,6 @@ GenTree* MorphInitBlockHelper::Morph()
156150
assert(m_transformationDecision != BlockTransformation::Undefined);
157151
assert(m_result != nullptr);
158152

159-
if (m_result != m_asg)
160-
{
161-
const bool isLateArg = ((m_asg->gtFlags & GTF_LATE_ARG) != 0);
162-
assert(m_isLateArg == isLateArg);
163-
if (isLateArg)
164-
{
165-
assert(!m_initBlock && "do not expect a block init as a late arg.");
166-
m_result->gtFlags |= GTF_LATE_ARG;
167-
}
168-
}
169-
170153
#ifdef DEBUG
171154
if (m_result != m_asg)
172155
{

0 commit comments

Comments
 (0)