1; RUN: opt < %s -S -nvptx-lower-alloca -infer-address-spaces | FileCheck %s 2; RUN: opt < %s -S -nvptx-lower-alloca | FileCheck %s --check-prefix LOWERALLOCAONLY 3; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_35 | FileCheck %s --check-prefix PTX 4; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64 -mcpu=sm_35 | %ptxas-verify %} 5 6target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64" 7target triple = "nvptx64-unknown-unknown" 8 9define ptx_kernel void @kernel() { 10; LABEL: @lower_alloca 11; PTX-LABEL: .visible .entry kernel( 12 %A = alloca i32 13; CHECK: addrspacecast ptr %A to ptr addrspace(5) 14; CHECK: store i32 0, ptr addrspace(5) {{%.+}} 15; LOWERALLOCAONLY: [[V1:%.*]] = addrspacecast ptr %A to ptr addrspace(5) 16; LOWERALLOCAONLY: [[V2:%.*]] = addrspacecast ptr addrspace(5) [[V1]] to ptr 17; LOWERALLOCAONLY: store i32 0, ptr [[V2]], align 4 18; PTX: st.local.u32 [{{%rd[0-9]+}}], {{%r[0-9]+}} 19 store i32 0, ptr %A 20 call void @callee(ptr %A) 21 ret void 22} 23 24define void @alloca_in_explicit_local_as() { 25; LABEL: @lower_alloca_addrspace5 26; PTX-LABEL: .visible .func alloca_in_explicit_local_as( 27 %A = alloca i32, addrspace(5) 28; CHECK: store i32 0, ptr addrspace(5) {{%.+}} 29; PTX: st.local.u32 [%SP], {{%r[0-9]+}} 30; LOWERALLOCAONLY: [[V1:%.*]] = addrspacecast ptr addrspace(5) %A to ptr 31; LOWERALLOCAONLY: store i32 0, ptr [[V1]], align 4 32 store i32 0, ptr addrspace(5) %A 33 call void @callee(ptr addrspace(5) %A) 34 ret void 35} 36 37declare void @callee(ptr) 38declare void @callee_addrspace5(ptr addrspace(5)) 39 40!nvvm.annotations = !{!1} 41!1 = !{ptr @alloca_in_explicit_local_as, !"alloca_in_explicit_local_as", i32 1} 42