Skip to content

Commit aa6512e

Browse files
committed
AArch64: Use reportFatalUsageError for unsupported calling conv
This probably should emit a DiagnosticInfoUnsupported and use the default calling convention instead, but then we would need to pass in the context. Also move where CCAssignFnForCall is called. It was unnecessarily called for each argument, so the error wouldn't trigger for functions with 0 arguments. This only ensures the error occurs for functions defined with the calling convention. The error is still missed for outgoing calls with no arguments. The lowering logic here is convoluted, calling CCAssignFnForCall for each argument and it does not mirror LowerFormalArguments so I'm not sure what's going on here.
1 parent 351303c commit aa6512e

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7632,7 +7632,7 @@ CCAssignFn *AArch64TargetLowering::CCAssignFnForCall(CallingConv::ID CC,
76327632
bool IsVarArg) const {
76337633
switch (CC) {
76347634
default:
7635-
report_fatal_error("Unsupported calling convention.");
7635+
reportFatalUsageError("unsupported calling convention");
76367636
case CallingConv::GHC:
76377637
return CC_AArch64_GHC;
76387638
case CallingConv::PreserveNone:
@@ -7741,6 +7741,12 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
77417741
unsigned NumArgs = Ins.size();
77427742
Function::const_arg_iterator CurOrigArg = F.arg_begin();
77437743
unsigned CurArgIdx = 0;
7744+
bool UseVarArgCC = false;
7745+
if (IsWin64)
7746+
UseVarArgCC = isVarArg;
7747+
7748+
CCAssignFn *AssignFn = CCAssignFnForCall(CallConv, UseVarArgCC);
7749+
77447750
for (unsigned i = 0; i != NumArgs; ++i) {
77457751
MVT ValVT = Ins[i].VT;
77467752
if (Ins[i].isOrigArg()) {
@@ -7757,10 +7763,6 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
77577763
else if (ActualMVT == MVT::i16)
77587764
ValVT = MVT::i16;
77597765
}
7760-
bool UseVarArgCC = false;
7761-
if (IsWin64)
7762-
UseVarArgCC = isVarArg;
7763-
CCAssignFn *AssignFn = CCAssignFnForCall(CallConv, UseVarArgCC);
77647766
bool Res =
77657767
AssignFn(i, ValVT, ValVT, CCValAssign::Full, Ins[i].Flags, CCInfo);
77667768
assert(!Res && "Call operand has unhandled type");
@@ -8429,6 +8431,8 @@ static void analyzeCallOperands(const AArch64TargetLowering &TLI,
84298431
ArgVT = MVT::i16;
84308432
}
84318433

8434+
// FIXME: CCAssignFnForCall should be called once, for the call and not per
8435+
// argument. This logic should exactly mirror LowerFormalArguments.
84328436
CCAssignFn *AssignFn = TLI.CCAssignFnForCall(CalleeCC, UseVarArgCC);
84338437
bool Res = AssignFn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, CCInfo);
84348438
assert(!Res && "Call operand has unhandled type");
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; FIXME: This should error:
2+
; RUN: llc -mtriple=aarch64-- -filetype=null %s
3+
declare amdgpu_gfx void @amdgpu_gfx_func()
4+
5+
define void @call_amdgpu_gfx_func() {
6+
call amdgpu_gfx void @amdgpu_gfx_func()
7+
ret void
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
; RUN: not llc -mtriple=aarch64-- -filetype=null %s 2>&1 | FileCheck %s
2+
3+
; CHECK: LLVM ERROR: unsupported calling convention
4+
define amdgpu_gfx void @amdgpu_gfx_func_definition() {
5+
ret void
6+
}

0 commit comments

Comments
 (0)