1; RUN: opt -data-layout=A5 -S -mtriple=amdgcn-unknown-unknown -amdgpu-promote-alloca -disable-promote-alloca-to-vector < %s | FileCheck %s
2
3; Make sure that AMDGPUPromoteAlloca doesn't crash if the called
4; function is a constantexpr cast of a function.
5
6declare void @foo(float addrspace(5)*) #0
7declare void @foo.varargs(...) #0
8
9; CHECK-LABEL: @crash_call_constexpr_cast(
10; CHECK: alloca
11; CHECK: call void
12define amdgpu_kernel void @crash_call_constexpr_cast() #0 {
13  %alloca = alloca i32, addrspace(5)
14  call void bitcast (void (float addrspace(5)*)* @foo to void (i32 addrspace(5)*)*)(i32 addrspace(5)* %alloca) #0
15  ret void
16}
17
18; CHECK-LABEL: @crash_call_constexpr_cast_varargs(
19; CHECK: alloca
20; CHECK: call void
21define amdgpu_kernel void @crash_call_constexpr_cast_varargs() #0 {
22  %alloca = alloca i32, addrspace(5)
23  call void bitcast (void (...)* @foo.varargs to void (i32 addrspace(5)*)*)(i32 addrspace(5)* %alloca) #0
24  ret void
25}
26
27attributes #0 = { nounwind }
28