1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals 2; RUN: opt -mtriple=amdgcn-- -passes=amdgpu-printf-runtime-binding -S < %s | FileCheck --check-prefix=GCN %s 3 4; Make sure the correct index is used for newly added entries to 5; llvm.printf.fmts if one already exists in the module. 6 7@format.str.one.int = private unnamed_addr addrspace(4) constant [8 x i8] c"arst %d\00", align 1 8 9; Inserted IDs should start at 2 10;. 11; GCN: @[[FORMAT_STR_ONE_INT:[a-zA-Z0-9_$"\\.-]+]] = private unnamed_addr addrspace(4) constant [8 x i8] c"arst %d\00", align 1 12;. 13define void @call_printf(i32 %n, i32 %m) { 14; GCN-LABEL: @call_printf( 15; GCN-NEXT: [[PRINTF_ALLOC_FN:%.*]] = call ptr addrspace(1) @__printf_alloc(i32 8) 16; GCN-NEXT: br label [[DOTSPLIT:%.*]] 17; GCN: .split: 18; GCN-NEXT: [[TMP1:%.*]] = icmp ne ptr addrspace(1) [[PRINTF_ALLOC_FN]], null 19; GCN-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]] 20; GCN: 2: 21; GCN-NEXT: [[PRINTBUFFID:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 0 22; GCN-NEXT: [[PRINTBUFFIDCAST:%.*]] = bitcast ptr addrspace(1) [[PRINTBUFFID]] to ptr addrspace(1) 23; GCN-NEXT: store i32 3, ptr addrspace(1) [[PRINTBUFFIDCAST]], align 4 24; GCN-NEXT: [[PRINTBUFFGEP:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 4 25; GCN-NEXT: store i32 [[N:%.*]], ptr addrspace(1) [[PRINTBUFFGEP]], align 4 26; GCN-NEXT: br label [[TMP3]] 27; GCN: 3: 28; GCN-NEXT: [[PRINTF_ALLOC_FN1:%.*]] = call ptr addrspace(1) @__printf_alloc(i32 8) 29; GCN-NEXT: br label [[DOTSPLIT2:%.*]] 30; GCN: .split2: 31; GCN-NEXT: [[TMP4:%.*]] = icmp ne ptr addrspace(1) [[PRINTF_ALLOC_FN1]], null 32; GCN-NEXT: br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP6:%.*]] 33; GCN: 5: 34; GCN-NEXT: [[PRINTBUFFID3:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN1]], i32 0 35; GCN-NEXT: [[PRINTBUFFIDCAST4:%.*]] = bitcast ptr addrspace(1) [[PRINTBUFFID3]] to ptr addrspace(1) 36; GCN-NEXT: store i32 4, ptr addrspace(1) [[PRINTBUFFIDCAST4]], align 4 37; GCN-NEXT: [[PRINTBUFFGEP5:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN1]], i32 4 38; GCN-NEXT: store i32 [[M:%.*]], ptr addrspace(1) [[PRINTBUFFGEP5]], align 4 39; GCN-NEXT: br label [[TMP6]] 40; GCN: 6: 41; GCN-NEXT: ret void 42; 43 %call0 = call i32 @printf(ptr addrspace(4) @format.str.one.int, i32 %n) 44 %call1 = call i32 @printf(ptr addrspace(4) @format.str.one.int, i32 %m) 45 ret void 46} 47 48declare i32 @printf(ptr addrspace(4), ...) 49 50!llvm.printf.fmts = !{!0, !1} 51 52!0 = !{!"49:2:4:4:%s\\72%d"} 53!1 = !{!"50:1:8:arst %p"} 54;. 55; GCN: attributes #[[ATTR0:[0-9]+]] = { nounwind } 56;. 57; GCN: [[META0:![0-9]+]] = !{!"49:2:4:4:%s\\72%d"} 58; GCN: [[META1:![0-9]+]] = !{!"50:1:8:arst %p"} 59; GCN: [[META2:![0-9]+]] = !{!"3:1:4:arst %d"} 60; GCN: [[META3:![0-9]+]] = !{!"4:1:4:arst %d"} 61;. 62