File: annotations.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 (149 lines) | stat: -rw-r--r-- 5,428 bytes parent folder | download | duplicates (12)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
; RUN: opt < %s -passes=instcombine -S | FileCheck --match-full-lines %s

; Test cases to make sure !annotation metadata is preserved, if possible.
; Currently we fail to preserve !annotation metadata in many cases.

; Make sure !annotation metadata is added to new instructions, if the source
; instruction has !annotation metadata.
define i1 @fold_to_new_instruction(ptr %a, ptr %b) {
; CHECK-LABEL: define {{.+}} @fold_to_new_instruction({{.+}}
; CHECK-NEXT:    [[C:%.*]] = icmp uge ptr [[A:%.*]], [[B:%[a-z]*]], !annotation [[ANN:![0-9]+]]
; CHECK-NEXT:    ret i1 [[C]]
;
  %c = icmp uge ptr %a, %b, !annotation !0
  ret i1 %c
}

; Make sure !annotation is not added to new instructions if the source
; instruction does not have it (even if some folded operands do have
; !annotation).
define i1 @fold_to_new_instruction2(ptr %a, ptr %b) {
; CHECK-LABEL: define {{.+}} @fold_to_new_instruction2({{.+}}
; CHECK-NEXT:    [[C:%.*]] = icmp uge ptr [[A:%.*]], [[B:%[a-z]+]]
; CHECK-NEXT:    ret i1 [[C]]
;
  %c = icmp uge ptr %a, %b
  ret i1 %c
}

; Make sure !annotation metadata is *not* added if we replace an instruction
; with !annotation with an existing one without.
define i32 @do_not_add_annotation_to_existing_instr(i32 %a, i32 %b) {
; CHECK-LABEL: define {{.+}} @do_not_add_annotation_to_existing_instr({{.+}}
; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[A:%.*]], [[B:%[a-z]+]]
; CHECK-NEXT:    ret i32 [[ADD]]
;
  %add = add i32 %a, %b
  %res = add i32 0, %add, !annotation !0
  ret i32 %res
}

; memcpy can be expanded inline with load/store. Verify that we keep the
; !annotation metadata.

declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind

define void @copy_1_byte(ptr %d, ptr %s) {
; CHECK-LABEL: define {{.+}} @copy_1_byte({{.+}}
; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[S:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    store i8 [[TMP1]], ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call void @llvm.memcpy.p0.p0.i32(ptr %d, ptr %s, i32 1, i1 false), !annotation !0
  ret void
}

declare ptr @memcpy(ptr noalias returned, ptr noalias nocapture readonly, i64) nofree nounwind

define void @libcallcopy_1_byte(ptr %d, ptr %s) {
; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte({{.+}}
; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[S:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    store i8 [[TMP1]], ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call ptr @memcpy(ptr %d, ptr %s, i64 1), !annotation !0
  ret void
}

declare ptr @__memcpy_chk(ptr, ptr, i64, i64) nofree nounwind

define void @libcallcopy_1_byte_chk(ptr %d, ptr %s) {
; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte_chk({{.+}}
; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[S:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    store i8 [[TMP1]], ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call ptr @__memcpy_chk(ptr %d, ptr %s, i64 1, i64 1), !annotation !0
  ret void
}

declare void @llvm.memmove.p0.p0.i32(ptr nocapture, ptr nocapture readonly, i32, i1) nounwind

define void @move_1_byte(ptr %d, ptr %s) {
; CHECK-LABEL: define {{.+}} @move_1_byte({{.+}}
; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[S:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    store i8 [[TMP1]], ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call void @llvm.memmove.p0.p0.i32(ptr %d, ptr %s, i32 1, i1 false), !annotation !0
  ret void
}

declare ptr @memmove(ptr returned, ptr nocapture readonly, i64) nofree nounwind

define void @libcallmove_1_byte(ptr %d, ptr %s) {
; CHECK-LABEL: define {{.+}} @libcallmove_1_byte({{.+}}
; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[S:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    store i8 [[TMP1]], ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call ptr @memmove(ptr %d, ptr %s, i64 1), !annotation !0
  ret void
}

declare ptr @__memmove_chk(ptr, ptr, i64, i64) nofree nounwind

define void @libcallmove_1_byte_chk(ptr %d, ptr %s) {
; CHECK-LABEL: define {{.+}} @libcallmove_1_byte_chk({{.+}}
; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[S:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    store i8 [[TMP1]], ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call ptr @__memmove_chk(ptr %d, ptr %s, i64 1, i64 1), !annotation !0
  ret void
}

declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1) argmemonly nounwind

define void @set_1_byte(ptr %d) {
; CHECK-LABEL: define {{.+}} @set_1_byte({{.+}}
; CHECK-NEXT:    store i8 1, ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call void @llvm.memset.p0.i32(ptr %d, i8 1, i32 1, i1 false), !annotation !0
  ret void
}

declare ptr @memset(ptr, i32, i64) nofree

define void @libcall_set_1_byte(ptr %d) {
; CHECK-LABEL: define {{.+}} @libcall_set_1_byte({{.+}}
; CHECK-NEXT:    store i8 1, ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call ptr @memset(ptr %d, i32 1, i64 1), !annotation !0
  ret void
}

declare ptr @__memset_chk(ptr, i32, i64, i64) nofree

define void @libcall_set_1_byte_chk(ptr %d) {
; CHECK-LABEL: define {{.+}} @libcall_set_1_byte_chk({{.+}}
; CHECK-NEXT:    store i8 1, ptr [[D:%.*]], align 1, !annotation [[ANN]]
; CHECK-NEXT:    ret void
;
  call ptr @__memset_chk(ptr %d, i32 1, i64 1, i64 1), !annotation !0
  ret void
}

!0 = !{ !"auto-init" }