blob: 72404b3088fe6928d6762d04e8e547b061740451 [file] [log] [blame]
Sanjoy Dasa942d772016-12-11 20:07:15 +00001; RUN: not llvm-as < %s 2>&1 | FileCheck %s
Adrian Prantl733fe2f2017-10-02 18:31:29 +00002; RUN: llvm-as -disable-verify < %s | opt -verify -S | FileCheck %s --check-prefix=STRIP
Sanjoy Dasa942d772016-12-11 20:07:15 +00003
Mehdi Aminice07e022016-12-16 19:16:29 +00004; STRIP-NOT: tbaa
5; STRIP: @f_0
6; STRIP: Do no strip this
Sanjoy Dasa942d772016-12-11 20:07:15 +00007define void @f_0(i32* %ptr) {
8; This part checks for the easy syntactic verifier rules.
9
10; CHECK: Struct tag metadata must have either 3 or 4 operands
11; CHECK-NEXT: store i32 0, i32* %ptr, !tbaa !{{[0-9]+}}
12
13; CHECK: Immutability tag on struct tag metadata must be a constant
14; CHECK-NEXT: store i32 1, i32* %ptr, !tbaa !{{[0-9]+}}
15
16; CHECK: Immutability part of the struct tag metadata must be either 0 or 1
17; CHECK-NEXT: store i32 2, i32* %ptr, !tbaa !{{[0-9]+}}
18
19; CHECK: Offset must be constant integer
20; CHECK-NEXT: store i32 3, i32* %ptr, !tbaa !{{[0-9]+}}
21
22; CHECK: Malformed struct tag metadata: base and access-type should be non-null and point to Metadata nodes
23; CHECK-NEXT: store i32 4, i32* %ptr, !tbaa !{{[0-9]+}}
24
Sanjoy Dasd9c611c2016-12-29 15:47:05 +000025; CHECK: Access type node must be a valid scalar type
Sanjoy Dasa942d772016-12-11 20:07:15 +000026; CHECK-NEXT: store i32 5, i32* %ptr, !tbaa !{{[0-9]+}}
27
28; CHECK: Access bit-width not the same as description bit-width
29; CHECK-NEXT: store i32 6, i32* %ptr, !tbaa !{{[0-9]+}}
30
Sanjoy Dasd9c611c2016-12-29 15:47:05 +000031; CHECK: Access type node must be a valid scalar type
Sanjoy Dasa942d772016-12-11 20:07:15 +000032; CHECK-NEXT: store i32 7, i32* %ptr, !tbaa !{{[0-9]+}}
33
Sanjoy Dasd9c611c2016-12-29 15:47:05 +000034; CHECK: Struct tag nodes have a string as their first operand
35; CHECK-NEXT: !{{[0-9]+}} = !{!{{[0-9]+}}, !{{[0-9]+}}, i64 0}
36
37; CHECK: Access type node must be a valid scalar type
38; CHECK-NEXT: store i32 9, i32* %ptr, !tbaa !{{[0-9]+}}
39
Sanjoy Dasa942d772016-12-11 20:07:15 +000040 store i32 0, i32* %ptr, !tbaa !{!3, !2, i64 40, i64 0, i64 1, i64 2}
41 store i32 1, i32* %ptr, !tbaa !{!3, !2, i64 40, !"immutable"}
42 store i32 2, i32* %ptr, !tbaa !{!3, !2, i64 40, i64 4}
43 store i32 3, i32* %ptr, !tbaa !{!3, !2, !"40", i64 0}
44 store i32 4, i32* %ptr, !tbaa !{!3, null, !"40", i64 0}
45 store i32 5, i32* %ptr, !tbaa !{!3, !3, !"40", i64 0}
46 store i32 6, i32* %ptr, !tbaa !{!3, !2, i32 40, i64 0}
Mehdi Aminice07e022016-12-16 19:16:29 +000047 store i32 7, i32* %ptr, !tbaa !{!3, !12, i32 40, i64 0}, !metadata !42
Sanjoy Dasd9c611c2016-12-29 15:47:05 +000048 store i32 8, i32* %ptr, !tbaa !{!13, !1, i64 0}
49 store i32 9, i32* %ptr, !tbaa !{!14, !14, i64 0}
Sanjoy Dasa942d772016-12-11 20:07:15 +000050 ret void
51}
Mehdi Aminice07e022016-12-16 19:16:29 +000052!42 = !{!"Do no strip this!"}
Sanjoy Dasa942d772016-12-11 20:07:15 +000053
54define void @f_1(i32* %ptr) {
55; This part checks for more semantic verifier rules.
56
57; CHECK: Cycle detected in struct path
58; CHECK-NEXT: store i32 0, i32* %ptr, !tbaa !{{[0-9]+}}
59
60; CHECK: Offset not zero at the point of scalar access
61; CHECK-NEXT: store i32 1, i32* %ptr, !tbaa !{{[0-9]+}}
62
63; CHECK: Offset not zero at the point of scalar access
64; CHECK-NEXT: store i32 2, i32* %ptr, !tbaa !{{[0-9]+}}
65
66; CHECK: Could not find TBAA parent in struct type node
67; CHECK-NEXT: store i32 3, i32* %ptr, !tbaa !{{[0-9]+}}
68
69; CHECK: Did not see access type in access path!
70; CHECK-NEXT: store i32 3, i32* %ptr, !tbaa !{{[0-9]+}}
71
Sanjoy Dasd9c611c2016-12-29 15:47:05 +000072; CHECK: Access type node must be a valid scalar type
Sanjoy Dasa942d772016-12-11 20:07:15 +000073; CHECK-NEXT: store i32 4, i32* %ptr, !tbaa !{{[0-9]+}}
74
Sanjoy Dasd9c611c2016-12-29 15:47:05 +000075; CHECK: Access type node must be a valid scalar type
Sanjoy Dasa942d772016-12-11 20:07:15 +000076; CHECK-NEXT: store i32 5, i32* %ptr, !tbaa !{{[0-9]+}}
77
Sanjoy Dasd9c611c2016-12-29 15:47:05 +000078; CHECK: Access type node must be a valid scalar type
Sanjoy Dasa942d772016-12-11 20:07:15 +000079; CHECK-NEXT: store i32 6, i32* %ptr, !tbaa !{{[0-9]+}}
80
81; CHECK: Struct tag nodes must have an odd number of operands!
82; CHECK-NEXT:!{{[0-9]+}} = !{!"bad-struct-type-0", !{{[0-9]+}}, i64 40, !{{[0-9]+}}}
83
84; CHECK: Incorrect field entry in struct type node!
85; CHECK-NEXT: store i32 8, i32* %ptr, !tbaa !{{[0-9]+}}
86
87; CHECK: Bitwidth between the offsets and struct type entries must match
88; CHECK-NEXT: store i32 9, i32* %ptr, !tbaa !{{[0-9]+}}
89
90; CHECK: Offsets must be increasing!
91; CHECK-NEXT: store i32 10, i32* %ptr, !tbaa !{{[0-9]+}}
92
93 store i32 0, i32* %ptr, !tbaa !{!4, !2, i64 40}
94 store i32 1, i32* %ptr, !tbaa !{!3, !2, i64 45}
95 store i32 2, i32* %ptr, !tbaa !{!3, !2, i64 45}
96 store i32 3, i32* %ptr, !tbaa !{!3, !2, i64 10}
97 store i32 4, i32* %ptr, !tbaa !{!5, !5, i64 0}
98 store i32 5, i32* %ptr, !tbaa !{!6, !6, i64 0}
99 store i32 6, i32* %ptr, !tbaa !{!7, !7, i64 0}
100 store i32 7, i32* %ptr, !tbaa !{!8, !1, i64 40}
101 store i32 8, i32* %ptr, !tbaa !{!9, !1, i64 40}
102 store i32 9, i32* %ptr, !tbaa !{!10, !1, i64 40}
103 store i32 10, i32* %ptr, !tbaa !{!11, !1, i64 40}
104 ret void
105}
106
107
108
109!0 = !{!"root"}
110!1 = !{!"scalar-a", !0}
111!2 = !{!"scalar-b", !0}
112!3 = !{!"struct-a", !2, i64 20, !1, i64 40}
113!4 = distinct !{!"self-recursive-struct", !2, i64 20, !4, i64 40}
114!5 = !{!"bad-scalar-0", i64 40}
115!6 = !{i64 42, !0}
116!7 = !{!"bad-scalar-1", null}
117!8 = !{!"bad-struct-type-0", !1, i64 40, !1}
118!9 = !{!"bad-struct-type-1", !1, i64 40, i64 56, !1}
119!10 = !{!"bad-struct-type-2", !1, i64 40, !1, i32 56}
120!11 = !{!"bad-struct-type-2", !1, i64 80, !1, i64 56}
121!12 = !{!"bad-scalar-2", !3, i64 0}
Sanjoy Dasd9c611c2016-12-29 15:47:05 +0000122!13 = !{!1, !1, i64 0}
123!14 = !{!"bad-scalar-2", !13}