@@ -235,60 +235,6 @@ void Compiler::lvaInitTypeRef()
235235
236236 lvaInitArgs (&varDscInfo);
237237
238- #if FEATURE_FASTTAILCALL
239-
240- // -------------------------------------------------------------------------
241- // Calculate the argument register usage.
242- //
243- // This will later be used for fastTailCall determination
244- // -------------------------------------------------------------------------
245-
246- unsigned argRegCount = 0 ;
247- unsigned floatingRegCount = 0 ;
248- size_t stackSize = 0 ;
249-
250- auto incrementRegCount = [&floatingRegCount, &argRegCount](LclVarDsc* varDsc) {
251- if (varDsc->lvIsHfa ())
252- {
253- floatingRegCount += varDsc->lvHfaSlots ();
254- }
255- else
256- {
257- varDsc->IsFloatRegType () ? ++floatingRegCount : ++argRegCount;
258- }
259- };
260-
261- unsigned argNum;
262- LclVarDsc* curDsc;
263-
264- for (curDsc = lvaTable, argNum = 0 ; argNum < varDscInfo.varNum ; argNum++, curDsc++)
265- {
266- if (curDsc->lvIsRegArg )
267- {
268- incrementRegCount (curDsc);
269- #if FEATURE_MULTIREG_ARGS
270- if (curDsc->lvOtherArgReg != REG_NA)
271- {
272- incrementRegCount (curDsc);
273- }
274- #endif // FEATURE_MULTIREG_ARGS
275- }
276- else
277- {
278- stackSize += curDsc->lvArgStackSize ();
279- }
280- }
281-
282- // -------------------------------------------------------------------------
283- // Save the register usage information and stack size.
284- // -------------------------------------------------------------------------
285-
286- info.compArgRegCount = argRegCount;
287- info.compFloatArgRegCount = floatingRegCount;
288- info.compArgStackSize = stackSize;
289-
290- #endif // FEATURE_FASTTAILCALL
291-
292238 // -------------------------------------------------------------------------
293239 // Finally the local variables
294240 // -------------------------------------------------------------------------
@@ -410,6 +356,13 @@ void Compiler::lvaInitArgs(InitVarDscInfo* varDscInfo)
410356 codeGen->floatRegState .rsCalleeRegArgCount = varDscInfo->floatRegArgNum ;
411357#endif // FEATURE_STACK_FP_X87
412358
359+ #if FEATURE_FASTTAILCALL
360+ // Save the stack usage information
361+ // We can get register usage information using codeGen->intRegState and
362+ // codeGen->floatRegState
363+ info.compArgStackSize = varDscInfo->stackArgSize ;
364+ #endif // FEATURE_FASTTAILCALL
365+
413366 // The total argument size must be aligned.
414367 noway_assert ((compArgSize % sizeof (void *)) == 0 );
415368
@@ -978,7 +931,6 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo)
978931 else
979932 {
980933#if defined(_TARGET_ARM_)
981-
982934 varDscInfo->setAllRegArgUsed (argType);
983935 if (varTypeIsFloating (argType))
984936 {
@@ -994,6 +946,10 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo)
994946 varDscInfo->setAllRegArgUsed (argType);
995947
996948#endif // _TARGET_XXX_
949+
950+ #if FEATURE_FASTTAILCALL
951+ varDscInfo->stackArgSize += (unsigned )roundUp (argSize, TARGET_POINTER_SIZE);
952+ #endif // FEATURE_FASTTAILCALL
997953 }
998954
999955#ifdef FEATURE_UNIX_AMD64_STRUCT_PASSING
@@ -1090,6 +1046,9 @@ void Compiler::lvaInitGenericsCtxt(InitVarDscInfo* varDscInfo)
10901046 // For the RyuJIT backend, we need to mark these as being on the stack,
10911047 // as this is not done elsewhere in the case that canEnreg returns false.
10921048 varDsc->lvOnFrame = true ;
1049+ #if FEATURE_FASTTAILCALL
1050+ varDscInfo->stackArgSize += TARGET_POINTER_SIZE;
1051+ #endif // FEATURE_FASTTAILCALL
10931052 }
10941053#endif // !LEGACY_BACKEND
10951054
@@ -1163,6 +1122,9 @@ void Compiler::lvaInitVarArgsHandle(InitVarDscInfo* varDscInfo)
11631122 // For the RyuJIT backend, we need to mark these as being on the stack,
11641123 // as this is not done elsewhere in the case that canEnreg returns false.
11651124 varDsc->lvOnFrame = true ;
1125+ #if FEATURE_FASTTAILCALL
1126+ varDscInfo->stackArgSize += TARGET_POINTER_SIZE;
1127+ #endif // FEATURE_FASTTAILCALL
11661128 }
11671129#endif // !LEGACY_BACKEND
11681130
0 commit comments