1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -mtriple=amdgcn-- -passes=amdgpu-printf-runtime-binding -mcpu=gfx90a -S < %s | FileCheck --check-prefix=GCN %s
4 @str = private unnamed_addr constant [10 x i8] c"string %d\00", align 1
6 define void @caller(i32 %n) {
7 ; GCN-LABEL: define void @caller
8 ; GCN-SAME: (i32 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
10 ; GCN-NEXT: [[CALL:%.*]] = call i32 (ptr, ...) @printf(ptr @str, i32 [[N]]) #[[ATTR2:[0-9]+]]
14 %call = call i32 (ptr, ...) @printf(ptr @str, i32 %n) #0
18 define void @caller_builtin(i32 %n) {
19 ; GCN-LABEL: define void @caller_builtin
20 ; GCN-SAME: (i32 [[N:%.*]]) #[[ATTR0]] {
22 ; GCN-NEXT: [[PRINTF_ALLOC_FN:%.*]] = call ptr addrspace(1) @__printf_alloc(i32 8)
23 ; GCN-NEXT: br label [[ENTRY_SPLIT:%.*]]
25 ; GCN-NEXT: [[TMP0:%.*]] = icmp ne ptr addrspace(1) [[PRINTF_ALLOC_FN]], null
26 ; GCN-NEXT: br i1 [[TMP0]], label [[TMP1:%.*]], label [[TMP2:%.*]]
28 ; GCN-NEXT: [[PRINTBUFFID:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 0
29 ; GCN-NEXT: [[PRINTBUFFIDCAST:%.*]] = bitcast ptr addrspace(1) [[PRINTBUFFID]] to ptr addrspace(1)
30 ; GCN-NEXT: store i32 1, ptr addrspace(1) [[PRINTBUFFIDCAST]], align 4
31 ; GCN-NEXT: [[PRINTBUFFGEP:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 4
32 ; GCN-NEXT: store i32 [[N]], ptr addrspace(1) [[PRINTBUFFGEP]], align 4
33 ; GCN-NEXT: br label [[TMP2]]
38 %call = call i32 (ptr, ...) @printf(ptr @str, i32 %n)
42 declare i32 @printf(ptr, ...)
44 attributes #0 = { nobuiltin }