1; RUN: opt -mtriple=r600-- -amdgpu-printf-runtime-binding -mcpu=r600 -S < %s | FileCheck --check-prefix=FUNC --check-prefix=R600 %s 2; RUN: opt -mtriple=amdgcn-- -amdgpu-printf-runtime-binding -mcpu=fiji -S < %s | FileCheck --check-prefix=FUNC --check-prefix=GCN %s 3; RUN: opt -mtriple=amdgcn--amdhsa -amdgpu-printf-runtime-binding -mcpu=fiji -S < %s | FileCheck --check-prefix=FUNC --check-prefix=GCN %s 4; RUN: opt -mtriple=amdgcn--amdhsa -passes=amdgpu-printf-runtime-binding -mcpu=fiji -S < %s | FileCheck --check-prefix=FUNC --check-prefix=GCN %s 5 6; FUNC-LABEL: @test_kernel( 7; R600-LABEL: entry 8; R600-NOT: call i8 addrspace(1)* @__printf_alloc 9; R600: call i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str, i32 0, i32 0), i8* %arraydecay, i32 %n) 10; GCN-LABEL: entry 11; GCN: call i8 addrspace(1)* @__printf_alloc 12; GCN-LABEL: entry.split 13; GCN: icmp ne i8 addrspace(1)* %printf_alloc_fn, null 14; GCN: %PrintBuffID = getelementptr i8, i8 addrspace(1)* %printf_alloc_fn, i32 0 15; GCN: %PrintBuffIdCast = bitcast i8 addrspace(1)* %PrintBuffID to i32 addrspace(1)* 16; GCN: store i32 1, i32 addrspace(1)* %PrintBuffIdCast 17; GCN: %PrintBuffGep = getelementptr i8, i8 addrspace(1)* %printf_alloc_fn, i32 4 18; GCN: %PrintArgPtr = ptrtoint i8* %arraydecay to i64 19; GCN: %PrintBuffPtrCast = bitcast i8 addrspace(1)* %PrintBuffGep to i64 addrspace(1)* 20; GCN: store i64 %PrintArgPtr, i64 addrspace(1)* %PrintBuffPtrCast 21; GCN: %PrintBuffNextPtr = getelementptr i8, i8 addrspace(1)* %PrintBuffGep, i32 8 22; GCN: %PrintBuffPtrCast1 = bitcast i8 addrspace(1)* %PrintBuffNextPtr to i32 addrspace(1)* 23; GCN: store i32 %n, i32 addrspace(1)* %PrintBuffPtrCast1 24 25@.str = private unnamed_addr addrspace(2) constant [6 x i8] c"%s:%d\00", align 1 26 27define amdgpu_kernel void @test_kernel(i32 %n) { 28entry: 29 %str = alloca [9 x i8], align 1 30 %arraydecay = getelementptr inbounds [9 x i8], [9 x i8]* %str, i32 0, i32 0 31 %call1 = call i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str, i32 0, i32 0), i8* %arraydecay, i32 %n) 32 ret void 33} 34 35declare i32 @printf(i8 addrspace(2)*, ...) 36