Skip to content

Commit

Permalink
Add a user facing error message for export proc argument mismatch
Browse files Browse the repository at this point in the history
Signed-off-by: Engin Kayraklioglu <[email protected]>
  • Loading branch information
e-kayrakli committed Mar 20, 2024
1 parent b339611 commit 2372a45
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion compiler/codegen/cg-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2938,7 +2938,7 @@ static GenRet codegenCallExprInner(GenRet function,
for (size_t i = 0; i < args.size(); i++) {
const clang::CodeGen::ABIArgInfo* argInfo = NULL;
if (CGI) {
argInfo = getCGArgInfo(CGI, i);
argInfo = getCGArgInfo(CGI, i, fn);
} else if (args[i].isLVPtr == GEN_VAL && useDarwinArmFix(args[i].chplType)) {
argInfo = getSingleCGArgInfo(args[i].chplType);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/codegen/cg-symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ codegenFunctionTypeLLVM(FnSymbol* fn, llvm::AttributeList& attrs,
for_formals(formal, fn) {
const clang::CodeGen::ABIArgInfo* argInfo = NULL;
if (CGI) {
argInfo = getCGArgInfo(CGI, clangArgNum);
argInfo = getCGArgInfo(CGI, clangArgNum, fn);
} else if (useDarwinArmFix(formal->type)) {
argInfo = getSingleCGArgInfo(formal->type);
}
Expand Down Expand Up @@ -2767,7 +2767,7 @@ void FnSymbol::codegenDef() {
for_formals(arg, this) {
const clang::CodeGen::ABIArgInfo* argInfo = NULL;
if (CGI) {
argInfo = getCGArgInfo(CGI, clangArgNum);
argInfo = getCGArgInfo(CGI, clangArgNum, this);
} else if (useDarwinArmFix(arg->type)) {
argInfo = getSingleCGArgInfo(arg->type);
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/include/clangUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ const clang::CodeGen::CGFunctionInfo& getClangABIInfoFD(clang::FunctionDecl* FD)
const clang::CodeGen::CGFunctionInfo& getClangABIInfo(FnSymbol* fn);

const clang::CodeGen::ABIArgInfo*
getCGArgInfo(const clang::CodeGen::CGFunctionInfo* CGI, int curCArg);
getCGArgInfo(const clang::CodeGen::CGFunctionInfo* CGI, int curCArg,
FnSymbol* fn=nullptr);

const clang::CodeGen::ABIArgInfo*
getSingleCGArgInfo(Type* type);
Expand Down
14 changes: 11 additions & 3 deletions compiler/llvm/clangUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4002,17 +4002,25 @@ const clang::CodeGen::CGFunctionInfo& getClangABIInfo(FnSymbol* fn) {
}

const clang::CodeGen::ABIArgInfo*
getCGArgInfo(const clang::CodeGen::CGFunctionInfo* CGI, int curCArg)
getCGArgInfo(const clang::CodeGen::CGFunctionInfo* CGI, int curCArg,
FnSymbol* fn)
{

// Don't try to use the calling convention code for variadic args.
if ((unsigned) curCArg >= CGI->arg_size() && CGI->isVariadic())
return NULL;
if ((unsigned) curCArg >= CGI->arg_size()) {
if (CGI->isVariadic()) {
return NULL;
}
else {
USR_FATAL(fn, "Argument number mismatch in export proc");
}
}

const clang::CodeGen::ABIArgInfo* argInfo = NULL;
#if HAVE_LLVM_VER >= 100
llvm::ArrayRef<clang::CodeGen::CGFunctionInfoArgInfo> a=CGI->arguments();
argInfo = &a[curCArg].info;

#else
int i = 0;
for (auto &ii : CGI->arguments()) {
Expand Down

0 comments on commit 2372a45

Please sign in to comment.