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

Commit 2486b80

Browse files
committed
Fix arm32 stub indirect tailcall
ARM has code in fgMorphTailCall to insert a level of indirection for the call address of a stub indirect tailcall. Then, LowerVirtualStubCall inserts another level of indirection. Only one is necessary/required, so stop inserting the second indirection in LowerVirtualStubCall. Fixes #15152, #14862 (all current TailcallStress=1 and JitStress=1 failures).
1 parent 30d20fd commit 2486b80

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/jit/lower.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4138,12 +4138,27 @@ GenTree* Lowering::LowerVirtualStubCall(GenTreeCall* call)
41384138
// fgMorphArgs will have created trees to pass the address in VirtualStubParam.reg.
41394139
// All we have to do here is add an indirection to generate the actual call target.
41404140

4141-
GenTree* ind = Ind(call->gtCallAddr);
4141+
GenTree* ind;
4142+
4143+
#ifdef _TARGET_ARM_
4144+
// For ARM, fgMorphTailCall has already made gtCallAddr a GT_IND for virtual stub tail calls.
4145+
// (When we eliminate LEGACY_BACKEND maybe we can eliminate this asymmetry?)
4146+
if (call->IsTailCallViaHelper())
4147+
{
4148+
ind = call->gtCallAddr;
4149+
assert(ind->gtOper == GT_IND);
4150+
}
4151+
else
4152+
#endif // _TARGET_ARM_
4153+
{
4154+
ind = Ind(call->gtCallAddr);
4155+
BlockRange().InsertAfter(call->gtCallAddr, ind);
4156+
call->gtCallAddr = ind;
4157+
}
4158+
41424159
ind->gtFlags |= GTF_IND_REQ_ADDR_IN_REG;
41434160

4144-
BlockRange().InsertAfter(call->gtCallAddr, ind);
41454161
ContainCheckIndir(ind->AsIndir());
4146-
call->gtCallAddr = ind;
41474162
}
41484163
else
41494164
{

0 commit comments

Comments
 (0)