Skip to content

Commit 06e08f3

Browse files
authored
AArch64: Use reportFatalUsageError for unsupported calling conv (llvm#144840)
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 0f302f3 commit 06e08f3

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
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+
}

llvm/test/MC/AArch64/coff-function-type-info.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
; RUN: llc -mtriple arm64-windows -filetype asm -o - %s \
1+
; RUN: llc -mtriple arm64-windows -filetype asm -o - %s \
22
; RUN: | FileCheck %s -check-prefix CHECK-ASM
33

44
; RUN: llc -mtriple arm64-windows -filetype obj -o - %s \
55
; RUN: | llvm-readobj --symbols - | FileCheck %s -check-prefix CHECK-OBJECT
66

7-
define arm_aapcs_vfpcc void @external() {
7+
define aarch64_vector_pcs void @external() {
88
entry:
99
ret void
1010
}
@@ -15,7 +15,7 @@ entry:
1515
; CHECK-ASM: .endef
1616
; CHECK-ASM: .globl external
1717

18-
define internal arm_aapcs_vfpcc void @internal() {
18+
define internal aarch64_vector_pcs void @internal() {
1919
entry:
2020
ret void
2121
}

0 commit comments

Comments
 (0)