File: printf-existing-format-strings.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (61 lines) | stat: -rw-r--r-- 2,886 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -mtriple=amdgcn-- -passes=amdgpu-printf-runtime-binding -S < %s | FileCheck --check-prefix=GCN %s

; Make sure the correct index is used for newly added entries to
; llvm.printf.fmts if one already exists in the module.

@format.str.one.int = private unnamed_addr addrspace(4) constant [8 x i8] c"arst %d\00", align 1

; Inserted IDs should start at 2
;.
; GCN: @[[FORMAT_STR_ONE_INT:[a-zA-Z0-9_$"\\.-]+]] = private unnamed_addr addrspace(4) constant [8 x i8] c"arst %d\00", align 1
;.
define void @call_printf(i32 %n, i32 %m) {
; GCN-LABEL: @call_printf(
; GCN-NEXT:    [[PRINTF_ALLOC_FN:%.*]] = call ptr addrspace(1) @__printf_alloc(i32 8)
; GCN-NEXT:    br label [[DOTSPLIT:%.*]]
; GCN:       .split:
; GCN-NEXT:    [[TMP1:%.*]] = icmp ne ptr addrspace(1) [[PRINTF_ALLOC_FN]], null
; GCN-NEXT:    br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
; GCN:       2:
; GCN-NEXT:    [[PRINTBUFFID:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 0
; GCN-NEXT:    [[PRINTBUFFIDCAST:%.*]] = bitcast ptr addrspace(1) [[PRINTBUFFID]] to ptr addrspace(1)
; GCN-NEXT:    store i32 3, ptr addrspace(1) [[PRINTBUFFIDCAST]], align 4
; GCN-NEXT:    [[PRINTBUFFGEP:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 4
; GCN-NEXT:    store i32 [[N:%.*]], ptr addrspace(1) [[PRINTBUFFGEP]], align 4
; GCN-NEXT:    br label [[TMP3]]
; GCN:       3:
; GCN-NEXT:    [[PRINTF_ALLOC_FN1:%.*]] = call ptr addrspace(1) @__printf_alloc(i32 8)
; GCN-NEXT:    br label [[DOTSPLIT2:%.*]]
; GCN:       .split2:
; GCN-NEXT:    [[TMP4:%.*]] = icmp ne ptr addrspace(1) [[PRINTF_ALLOC_FN1]], null
; GCN-NEXT:    br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP6:%.*]]
; GCN:       5:
; GCN-NEXT:    [[PRINTBUFFID3:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN1]], i32 0
; GCN-NEXT:    [[PRINTBUFFIDCAST4:%.*]] = bitcast ptr addrspace(1) [[PRINTBUFFID3]] to ptr addrspace(1)
; GCN-NEXT:    store i32 4, ptr addrspace(1) [[PRINTBUFFIDCAST4]], align 4
; GCN-NEXT:    [[PRINTBUFFGEP5:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN1]], i32 4
; GCN-NEXT:    store i32 [[M:%.*]], ptr addrspace(1) [[PRINTBUFFGEP5]], align 4
; GCN-NEXT:    br label [[TMP6]]
; GCN:       6:
; GCN-NEXT:    ret void
;
  %call0 = call i32 @printf(ptr addrspace(4) @format.str.one.int, i32 %n)
  %call1 = call i32 @printf(ptr addrspace(4) @format.str.one.int, i32 %m)
  ret void
}

declare i32 @printf(ptr addrspace(4), ...)

!llvm.printf.fmts = !{!0, !1}

!0 = !{!"49:2:4:4:%s\\72%d"}
!1 = !{!"50:1:8:arst %p"}
;.
; GCN: attributes #[[ATTR0:[0-9]+]] = { nounwind }
;.
; GCN: [[META0:![0-9]+]] = !{!"49:2:4:4:%s\\72%d"}
; GCN: [[META1:![0-9]+]] = !{!"50:1:8:arst %p"}
; GCN: [[META2:![0-9]+]] = !{!"3:1:4:arst %d"}
; GCN: [[META3:![0-9]+]] = !{!"4:1:4:arst %d"}
;.