Skip to content

Commit

Permalink
[AMDGPU][DAGISel] Be more flexible about what calls are allowed
Browse files Browse the repository at this point in the history
Remove DAGISel checks on calling conventions. GlobalISel doesn't have
these checks either and we prefer it that way (see D152794).

Add a simple test like the one introduced in D117479 for GlobalISel.

Differential Revision: https://reviews.llvm.org/D153535
  • Loading branch information
rovka committed Jun 27, 2023
1 parent 8aa88ee commit d98e44b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
15 changes: 0 additions & 15 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3198,21 +3198,6 @@ SDValue SITargetLowering::LowerCall(CallLoweringInfo &CLI,
"unsupported required tail call to function ");
}

if (AMDGPU::isShader(CallConv)) {
// Note the issue is with the CC of the called function, not of the call
// itself.
return lowerUnhandledCall(CLI, InVals,
"unsupported call to a shader function ");
}

if (AMDGPU::isShader(MF.getFunction().getCallingConv()) &&
CallConv != CallingConv::AMDGPU_Gfx) {
// Only allow calls with specific calling conventions.
return lowerUnhandledCall(CLI, InVals,
"unsupported calling convention for call from "
"graphics shader of function ");
}

if (IsTailCall) {
IsTailCall = isEligibleForTailCallOptimization(
Callee, CallConv, IsVarArg, Outs, OutVals, Ins, DAG);
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/AMDGPU/call-c-function.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
; RUN: llc -global-isel=0 -stop-after=finalize-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -verify-machineinstrs -o - %s | FileCheck -enable-var-scope %s

; Test that we don't explode on calls from shaders to functions with the C calling convention.

define amdgpu_ps void @amdgpu_ps_call_default_cc() {
; CHECK-LABEL: name: amdgpu_ps_call_default_cc
; CHECK: bb.0.main_body:
; CHECK-NEXT: S_ENDPGM 0
main_body:
call void null()
ret void
}

define amdgpu_gfx void @amdgpu_gfx_call_default_cc() {
; CHECK-LABEL: name: amdgpu_gfx_call_default_cc
; CHECK: bb.0.main_body:
; CHECK-NEXT: SI_RETURN
main_body:
call void null()
ret void
}
1 change: 0 additions & 1 deletion llvm/test/CodeGen/AMDGPU/unsupported-calls.ll
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ define i32 @test_tail_call_bitcast_extern_variadic(<4 x float> %arg0, <4 x float
ret i32 %call
}

; GCN: :0:0: in function test_c_call_from_shader i32 (): unsupported calling convention for call from graphics shader of function defined_function
; R600: in function test_c_call{{.*}}: unsupported call to function defined_function
define amdgpu_ps i32 @test_c_call_from_shader() {
%call = call i32 @defined_function(i32 0)
Expand Down

0 comments on commit d98e44b

Please sign in to comment.