From 56f1e4a76b1f344e5bc3d971326022cf53b79957 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Thu, 15 Dec 2016 20:50:12 +0000 Subject: [PATCH] AMDGPU: Fix asserting on returned tail calls git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289868 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AMDGPU/AMDGPUISelLowering.cpp | 6 ++++-- test/CodeGen/AMDGPU/call.ll | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/lib/Target/AMDGPU/AMDGPUISelLowering.cpp index baf27971dd7..7109913a0b6 100644 --- a/lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ b/lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -789,8 +789,10 @@ SDValue AMDGPUTargetLowering::LowerCall(CallLoweringInfo &CLI, Fn, "unsupported call to function " + FuncName, CLI.DL.getDebugLoc()); DAG.getContext()->diagnose(NoCalls); - for (unsigned I = 0, E = CLI.Ins.size(); I != E; ++I) - InVals.push_back(DAG.getUNDEF(CLI.Ins[I].VT)); + if (!CLI.IsTailCall) { + for (unsigned I = 0, E = CLI.Ins.size(); I != E; ++I) + InVals.push_back(DAG.getUNDEF(CLI.Ins[I].VT)); + } return DAG.getEntryNode(); } diff --git a/test/CodeGen/AMDGPU/call.ll b/test/CodeGen/AMDGPU/call.ll index a3e986d367e..6d101e1537c 100644 --- a/test/CodeGen/AMDGPU/call.ll +++ b/test/CodeGen/AMDGPU/call.ll @@ -5,6 +5,7 @@ ; CHECK: in function test_call_external{{.*}}: unsupported call to function external_function ; CHECK: in function test_call{{.*}}: unsupported call to function defined_function ; CHECK: in function test_tail_call{{.*}}: unsupported call to function defined_function +; CHECK: in function test_tail_call_bitcast_extern_variadic{{.*}}: unsupported call to function extern_variadic declare i32 @external_function(i32) nounwind @@ -43,3 +44,16 @@ define void @test_tail_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { store i32 %result, i32 addrspace(1)* %out ret void } + +define i32 @test_tail_call_ret() { + %call = call i32 @external_function(i32 10) + ret i32 %call +} + +declare i32 @extern_variadic(...) + +define i32 @test_tail_call_bitcast_extern_variadic(<4 x float> %arg0, <4 x float> %arg1, i32 %arg2) { + %add = fadd <4 x float> %arg0, %arg1 + %call = tail call i32 bitcast (i32 (...)* @extern_variadic to i32 (<4 x float>)*)(<4 x float> %add) #7 + ret i32 %call +} -- 2.11.0