1; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s
2
3; This is just an arbitrary intrinisic that shouldn't ever need to be
4; handled to ensure it doesn't crash.
5
6declare void @llvm.stackrestore(i8*) #2
7
8; CHECK-LABEL: @try_promote_unhandled_intrinsic(
9; CHECK: alloca
10; CHECK: call void @llvm.stackrestore(i8* %tmp1)
11define amdgpu_kernel void @try_promote_unhandled_intrinsic(i32 addrspace(1)* %arg) #2 {
12bb:
13  %tmp = alloca i32, align 4
14  %tmp1 = bitcast i32* %tmp to i8*
15  %tmp2 = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 1
16  %tmp3 = load i32, i32 addrspace(1)* %tmp2
17  store i32 %tmp3, i32* %tmp
18  call void @llvm.stackrestore(i8* %tmp1)
19  ret void
20}
21
22attributes #0 = { argmemonly nounwind }
23attributes #1 = { nounwind readnone }
24attributes #2 = { nounwind }
25