1
+ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
1
2
// REQUIRES: system-darwin
2
- // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --replace-value-regex "!annotation ![0-9]+" "!tbaa ![0-9]+" "!tbaa\.struct ![0-9]+" "!nosanitize ![0-9]+" "!srcloc ![0-9]+" --prefix-filecheck-ir-name TMP_
3
-
4
3
5
4
// RUN: %clang_cc1 -O2 -triple x86_64 -fbounds-safety -emit-llvm %s -o - | FileCheck --check-prefixes O2 %s
6
5
// RUN: %clang_cc1 -O0 -triple x86_64 -fbounds-safety -emit-llvm %s -o - | FileCheck --check-prefixes O0 %s
@@ -12,34 +11,33 @@ struct S {
12
11
long i ;
13
12
};
14
13
15
- // O2-LABEL: @foo(
16
- // O2-NEXT: entry:
14
+ // O2-LABEL: define dso_local void @foo(
15
+ // O2-SAME: ptr noundef readnone captures(none) [[A:%.*]], i64 noundef [[I:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
16
+ // O2-NEXT: [[ENTRY:.*:]]
17
17
// O2-NEXT: [[S:%.*]] = alloca [[STRUCT_S:%.*]], align 8
18
18
// O2-NEXT: call void @llvm.lifetime.start.p0(i64 16, ptr nonnull [[S]]) #[[ATTR3:[0-9]+]]
19
- // O2-NEXT: store ptr [[A:%.*]], ptr [[S]], align 8, {{!tbaa ![0-9]+}}
20
- // O2-NEXT: [[I1:%.*]] = getelementptr inbounds nuw i8, ptr [[S]], i64 8
21
- // O2-NEXT: store i64 [[I:%.*]], ptr [[I1]], align 8, {{!tbaa ![0-9]+}}
22
19
// O2-NEXT: [[TMP0:%.*]] = getelementptr inbounds nuw i8, ptr [[S]], i64 16
23
20
// O2-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[S]], i64 24
24
- // O2-NEXT: [[DOTNOT:%.*]] = icmp ugt ptr [[TMP1]], [[TMP0]], {{ !annotation ![0-9]+}}
25
- // O2-NEXT: br i1 [[DOTNOT]], label [[TRAP:% .*]], label [[CONT9:% .*]], {{ !annotation ![0-9]+}}
26
- // O2: trap :
27
- // O2-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4:[0-9]+]], {{ !annotation ![0-9]+}}
28
- // O2-NEXT: unreachable, {{ !annotation ![0-9]+}}
29
- // O2: cont9 :
21
+ // O2-NEXT: [[DOTNOT:%.*]] = icmp ugt ptr [[TMP1]], [[TMP0]], !annotation [[META2: ![0-9]+]]
22
+ // O2-NEXT: br i1 [[DOTNOT]], label % [[TRAP:.*]], label % [[CONT9:.*]], !annotation [[META2]]
23
+ // O2: [[TRAP]] :
24
+ // O2-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR4:[0-9]+]], !annotation [[META3: ![0-9]+]]
25
+ // O2-NEXT: unreachable, !annotation [[META3]]
26
+ // O2: [[CONT9]] :
30
27
// O2-NEXT: call void @llvm.lifetime.end.p0(i64 16, ptr nonnull [[S]]) #[[ATTR3]]
31
28
// O2-NEXT: ret void
32
29
//
33
- // O0-LABEL: @foo(
34
- // O0-NEXT: entry:
30
+ // O0-LABEL: define dso_local void @foo(
31
+ // O0-SAME: ptr noundef [[A:%.*]], i64 noundef [[I:%.*]]) #[[ATTR0:[0-9]+]] {
32
+ // O0-NEXT: [[ENTRY:.*:]]
35
33
// O0-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
36
34
// O0-NEXT: [[I_ADDR:%.*]] = alloca i64, align 8
37
35
// O0-NEXT: [[S:%.*]] = alloca [[STRUCT_S:%.*]], align 8
38
36
// O0-NEXT: [[SP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8
39
37
// O0-NEXT: [[AGG_TEMP:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable.0", align 8
40
38
// O0-NEXT: [[AGG_TEMP2:%.*]] = alloca %"__bounds_safety::wide_ptr.bidi_indexable", align 8
41
- // O0-NEXT: store ptr [[A:%.* ]], ptr [[A_ADDR]], align 8
42
- // O0-NEXT: store i64 [[I:%.* ]], ptr [[I_ADDR]], align 8
39
+ // O0-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 8
40
+ // O0-NEXT: store i64 [[I]], ptr [[I_ADDR]], align 8
43
41
// O0-NEXT: [[P:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr [[S]], i32 0, i32 0
44
42
// O0-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
45
43
// O0-NEXT: store ptr [[TMP0]], ptr [[P]], align 8
@@ -66,8 +64,8 @@ struct S {
66
64
// O0-NEXT: store ptr [[WIDE_PTR_UB]], ptr [[TMP8]], align 8
67
65
// O0-NEXT: [[TMP9:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[SP]], i32 0, i32 2
68
66
// O0-NEXT: store ptr [[WIDE_PTR_LB]], ptr [[TMP9]], align 8
69
- // O0-NEXT: br label [[BINGO:% .*]]
70
- // O0: bingo :
67
+ // O0-NEXT: br label % [[BINGO:.*]]
68
+ // O0: [[BINGO]] :
71
69
// O0-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TEMP2]], ptr align 8 [[SP]], i64 24, i1 false)
72
70
// O0-NEXT: [[WIDE_PTR_PTR_ADDR3:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP2]], i32 0, i32 0
73
71
// O0-NEXT: [[WIDE_PTR_PTR4:%.*]] = load ptr, ptr [[WIDE_PTR_PTR_ADDR3]], align 8
@@ -76,18 +74,18 @@ struct S {
76
74
// O0-NEXT: [[WIDE_PTR_LB_ADDR7:%.*]] = getelementptr inbounds nuw %"__bounds_safety::wide_ptr.bidi_indexable", ptr [[AGG_TEMP2]], i32 0, i32 2
77
75
// O0-NEXT: [[WIDE_PTR_LB8:%.*]] = load ptr, ptr [[WIDE_PTR_LB_ADDR7]], align 8
78
76
// O0-NEXT: [[TMP10:%.*]] = getelementptr [[STRUCT_S]], ptr [[WIDE_PTR_PTR4]], i64 1
79
- // O0-NEXT: [[TMP11:%.*]] = icmp ule ptr [[TMP10]], [[WIDE_PTR_UB6]], {{ !annotation ![0-9]+}}
80
- // O0-NEXT: br i1 [[TMP11]], label [[CONT:% .*]], label [[TRAP:% .*]], {{ !annotation ![0-9]+}}
81
- // O0: trap :
82
- // O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], {{ !annotation ![0-9]+}}
83
- // O0-NEXT: unreachable, {{ !annotation ![0-9]+}}
84
- // O0: cont :
85
- // O0-NEXT: [[TMP12:%.*]] = icmp ule ptr [[WIDE_PTR_LB8]], [[WIDE_PTR_PTR4]], {{ !annotation ![0-9]+}}
86
- // O0-NEXT: br i1 [[TMP12]], label [[CONT10:% .*]], label [[TRAP9:% .*]], {{ !annotation ![0-9]+}}
87
- // O0: trap9 :
88
- // O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], {{ !annotation ![0-9]+}}
89
- // O0-NEXT: unreachable, {{ !annotation ![0-9]+}}
90
- // O0: cont10 :
77
+ // O0-NEXT: [[TMP11:%.*]] = icmp ule ptr [[TMP10]], [[WIDE_PTR_UB6]], !annotation [[META2: ![0-9]+]]
78
+ // O0-NEXT: br i1 [[TMP11]], label % [[CONT:.*]], label % [[TRAP:.*]], !annotation [[META2]]
79
+ // O0: [[TRAP]] :
80
+ // O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3:[0-9]+]], !annotation [[META2]]
81
+ // O0-NEXT: unreachable, !annotation [[META2]]
82
+ // O0: [[CONT]] :
83
+ // O0-NEXT: [[TMP12:%.*]] = icmp ule ptr [[WIDE_PTR_LB8]], [[WIDE_PTR_PTR4]], !annotation [[META3: ![0-9]+]]
84
+ // O0-NEXT: br i1 [[TMP12]], label % [[CONT10:.*]], label % [[TRAP9:.*]], !annotation [[META3]]
85
+ // O0: [[TRAP9]] :
86
+ // O0-NEXT: call void @llvm.ubsantrap(i8 25) #[[ATTR3]], !annotation [[META3]]
87
+ // O0-NEXT: unreachable, !annotation [[META3]]
88
+ // O0: [[CONT10]] :
91
89
// O0-NEXT: [[I11:%.*]] = getelementptr inbounds nuw [[STRUCT_S]], ptr [[WIDE_PTR_PTR4]], i32 0, i32 1
92
90
// O0-NEXT: store i64 3, ptr [[I11]], align 8
93
91
// O0-NEXT: ret void
@@ -99,4 +97,9 @@ bingo:;
99
97
sp -> i = 3 ; // run-time trap : oob
100
98
}
101
99
102
-
100
+ // O2: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"}
101
+ // O2: [[META3]] = !{!"bounds-safety-check-ptr-lt-upper-bound", !"bounds-safety-check-ptr-ge-lower-bound"}
102
+ //.
103
+ // O0: [[META2]] = !{!"bounds-safety-check-ptr-lt-upper-bound"}
104
+ // O0: [[META3]] = !{!"bounds-safety-check-ptr-ge-lower-bound"}
105
+ //.
0 commit comments