@@ -926,29 +926,36 @@ LowererMDArch::LowerCall(IR::Instr * callInstr, uint32 argCount)
926
926
#define _V_ARG_INDEX (index ) _vindex[(index) - 1 ]
927
927
#endif
928
928
929
+ // xplat NOTE: Lower often loads "known args" with LoadHelperArgument() and
930
+ // variadic JS runtime args with LowerCallArgs(). So the full args length is
931
+ // this->helperCallArgsCount + argCount
932
+ // "argCount > 0" indicates we have variadic JS runtime args and needs to
933
+ // manually home registers on xplat.
934
+ const bool shouldHomeParams = argCount > 0 ;
935
+
929
936
while (argsLeft > 0 )
930
937
{
931
938
IR::Opnd * helperSrc = this ->helperCallArgs [this ->helperCallArgsCount - argsLeft];
932
939
uint16 index = _V_ARG_INDEX (argsLeft);
933
940
StackSym * helperSym = m_func->m_symTable ->GetArgSlotSym (index);
934
941
helperSym->m_type = ExtendHelperArg (helperSrc->GetType ());
935
942
Lowerer::InsertMove (
936
- this ->GetArgSlotOpnd (index, helperSym, /* isHelper*/ true ),
943
+ this ->GetArgSlotOpnd (index, helperSym, /* isHelper*/ !shouldHomeParams ),
937
944
helperSrc,
938
945
callInstr);
939
946
--argsLeft;
940
947
}
941
948
942
949
#ifndef _WIN32
943
950
// Manually home args
944
- if (argCount > 0 )
951
+ if (shouldHomeParams )
945
952
{
946
953
static const RegNum s_argRegs[IntArgRegsCount] = {
947
954
#define REG_INT_ARG (Index, Name ) Reg ## Name,
948
955
#include " RegList.h"
949
956
};
950
957
951
- const int callArgCount = static_cast <int >(argCount) + this -> helperCallArgsCount ;
958
+ const int callArgCount = this -> helperCallArgsCount + static_cast <int >(argCount);
952
959
const int argRegs = min (callArgCount, static_cast <int >(IntArgRegsCount));
953
960
for (int i = argRegs - 1 ; i >= 0 ; i--)
954
961
{
0 commit comments