mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Fixed shadowing issue on varargs method on non-varargs param
This commit is contained in:
parent
a332f723d7
commit
9c79d8aa6c
2 changed files with 16 additions and 11 deletions
|
@ -2867,7 +2867,7 @@ BeMCOperand BeMCContext::GetCallArgVReg(int argIdx, BeTypeCode typeCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BeMCOperand BeMCContext::CreateCall(const BeMCOperand &func, const SizedArrayImpl<BeValue*>& args, BeType* retType, BfIRCallingConv callingConv, bool structRet, bool noReturn, bool isVarArg)
|
BeMCOperand BeMCContext::CreateCall(const BeMCOperand &func, const SizedArrayImpl<BeValue*>& args, BeType* retType, BfIRCallingConv callingConv, bool structRet, bool noReturn, int varArgStart)
|
||||||
{
|
{
|
||||||
SizedArray<BeMCOperand, 4> opArgs;
|
SizedArray<BeMCOperand, 4> opArgs;
|
||||||
for (auto itr = args.begin(); itr != args.end(); ++itr)
|
for (auto itr = args.begin(); itr != args.end(); ++itr)
|
||||||
|
@ -2875,7 +2875,7 @@ BeMCOperand BeMCContext::CreateCall(const BeMCOperand &func, const SizedArrayImp
|
||||||
auto& arg = *itr;
|
auto& arg = *itr;
|
||||||
opArgs.push_back(GetOperand(arg));
|
opArgs.push_back(GetOperand(arg));
|
||||||
}
|
}
|
||||||
return CreateCall(func, opArgs, retType, callingConv, structRet, noReturn, isVarArg);
|
return CreateCall(func, opArgs, retType, callingConv, structRet, noReturn, varArgStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
BeMCOperand BeMCContext::CreateLoad(const BeMCOperand& mcTarget)
|
BeMCOperand BeMCContext::CreateLoad(const BeMCOperand& mcTarget)
|
||||||
|
@ -3029,7 +3029,7 @@ void BeMCContext::CreateStore(BeMCInstKind instKind, const BeMCOperand& val, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BeMCOperand BeMCContext::CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType, BfIRCallingConv callingConv, bool structRet, bool noReturn, bool isVarArg)
|
BeMCOperand BeMCContext::CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType, BfIRCallingConv callingConv, bool structRet, bool noReturn, int varArgStart)
|
||||||
{
|
{
|
||||||
BeMCOperand mcResult;
|
BeMCOperand mcResult;
|
||||||
//TODO: Allow user to directly specify ret addr with "sret" attribute
|
//TODO: Allow user to directly specify ret addr with "sret" attribute
|
||||||
|
@ -3080,8 +3080,11 @@ BeMCOperand BeMCContext::CreateCall(const BeMCOperand& func, const SizedArrayImp
|
||||||
if ((argIdx == 0) && (compositeRetReg == X64Reg_RDX))
|
if ((argIdx == 0) && (compositeRetReg == X64Reg_RDX))
|
||||||
argOfs = 0;
|
argOfs = 0;
|
||||||
|
|
||||||
|
bool isVarArg = (varArgStart != -1) && (argIdx >= varArgStart);
|
||||||
|
|
||||||
auto mcValue = args[argIdx];
|
auto mcValue = args[argIdx];
|
||||||
auto argType = GetType(mcValue);
|
auto argType = GetType(mcValue);
|
||||||
|
|
||||||
X64CPURegister useReg = X64Reg_None;
|
X64CPURegister useReg = X64Reg_None;
|
||||||
int useArgIdx = argIdx + argOfs;
|
int useArgIdx = argIdx + argOfs;
|
||||||
|
|
||||||
|
@ -3122,7 +3125,7 @@ BeMCOperand BeMCContext::CreateCall(const BeMCOperand& func, const SizedArrayImp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVarArg)
|
if (isVarArg)
|
||||||
{
|
{
|
||||||
X64CPURegister shadowReg = X64Reg_None;
|
X64CPURegister shadowReg = X64Reg_None;
|
||||||
switch (useArgIdx)
|
switch (useArgIdx)
|
||||||
{
|
{
|
||||||
|
@ -3138,7 +3141,7 @@ BeMCOperand BeMCContext::CreateCall(const BeMCOperand& func, const SizedArrayImp
|
||||||
case 3:
|
case 3:
|
||||||
shadowReg = X64Reg_R9;
|
shadowReg = X64Reg_R9;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((shadowReg != X64Reg_None) && (useReg != X64Reg_None))
|
if ((shadowReg != X64Reg_None) && (useReg != X64Reg_None))
|
||||||
{
|
{
|
||||||
|
@ -17595,7 +17598,7 @@ void BeMCContext::Generate(BeFunction* function)
|
||||||
auto castedInst = (BeCallInst*)inst;
|
auto castedInst = (BeCallInst*)inst;
|
||||||
BeMCOperand mcFunc;
|
BeMCOperand mcFunc;
|
||||||
BeType* returnType = NULL;
|
BeType* returnType = NULL;
|
||||||
bool isVarArg = false;
|
int varArgStart = -1;
|
||||||
|
|
||||||
bool useAltArgs = false;
|
bool useAltArgs = false;
|
||||||
SizedArray<BeValue*, 6> args;
|
SizedArray<BeValue*, 6> args;
|
||||||
|
@ -18187,7 +18190,9 @@ void BeMCContext::Generate(BeFunction* function)
|
||||||
auto elementType = ((BePointerType*)funcPtrType)->mElementType;
|
auto elementType = ((BePointerType*)funcPtrType)->mElementType;
|
||||||
if (elementType->mTypeCode == BeTypeCode_Function)
|
if (elementType->mTypeCode == BeTypeCode_Function)
|
||||||
{
|
{
|
||||||
isVarArg = ((BeFunctionType*)elementType)->mIsVarArg;
|
BeFunctionType* funcType = (BeFunctionType*)elementType;
|
||||||
|
if (funcType->mIsVarArg)
|
||||||
|
varArgStart = funcType->mParams.mSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18204,7 +18209,7 @@ void BeMCContext::Generate(BeFunction* function)
|
||||||
args.Add(arg.mValue);
|
args.Add(arg.mValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = CreateCall(mcFunc, args, returnType, castedInst->mCallingConv, castedInst->HasStructRet(), castedInst->mNoReturn, isVarArg);
|
result = CreateCall(mcFunc, args, returnType, castedInst->mCallingConv, castedInst->HasStructRet(), castedInst->mNoReturn, varArgStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1377,8 +1377,8 @@ public:
|
||||||
void RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged = true, bool removeFromList = true);
|
void RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged = true, bool removeFromList = true);
|
||||||
BeMCOperand AllocBinaryOp(BeMCInstKind instKind, const BeMCOperand & lhs, const BeMCOperand & rhs, BeMCBinIdentityKind identityKind, BeMCOverflowCheckKind overflowCheckKind = BeMCOverflowCheckKind_None);
|
BeMCOperand AllocBinaryOp(BeMCInstKind instKind, const BeMCOperand & lhs, const BeMCOperand & rhs, BeMCBinIdentityKind identityKind, BeMCOverflowCheckKind overflowCheckKind = BeMCOverflowCheckKind_None);
|
||||||
BeMCOperand GetCallArgVReg(int argIdx, BeTypeCode typeCode);
|
BeMCOperand GetCallArgVReg(int argIdx, BeTypeCode typeCode);
|
||||||
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false);
|
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, int varArgStart = -1);
|
||||||
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeValue*>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false);
|
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeValue*>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, int varArgStart = -1);
|
||||||
BeMCOperand CreateLoad(const BeMCOperand& mcTarget);
|
BeMCOperand CreateLoad(const BeMCOperand& mcTarget);
|
||||||
void CreateStore(BeMCInstKind instKind, const BeMCOperand& val, const BeMCOperand& ptr);
|
void CreateStore(BeMCInstKind instKind, const BeMCOperand& val, const BeMCOperand& ptr);
|
||||||
void CreateMemSet(const BeMCOperand& addr, uint8 val, int size, int align);
|
void CreateMemSet(const BeMCOperand& addr, uint8 val, int size, int align);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue