xref: /llvm-project/clang/test/CodeGen/sanitize-type-globals.cpp (revision 473cdb93e55deeea6a7f654e192f5227d85cee08)
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals all --filter-out "attributes" --filter-out "attributes #" --version 5
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=type | FileCheck -check-prefix=CHECK %s
3 
4 //.
5 // CHECK: @x = global %struct.CompleteS zeroinitializer, align 8
6 // CHECK: @xExtern = external global %struct.CompleteS, align 8
7 // CHECK: @y = external global %struct.S, align 1
8 // CHECK: @d = global %class.b zeroinitializer, align 1
9 // CHECK: @_ZN1b1eE = external global %class.a, align 1
10 // CHECK: @__tysan_shadow_memory_address = external global i64
11 // CHECK: @__tysan_app_memory_mask = external global i64
12 // CHECK: @__tysan_v1_Simple_20C_2b_2b_20TBAA = linkonce_odr constant { i64, i64, [16 x i8] } { i64 2, i64 0, [16 x i8] c"Simple C++ TBAA\00" }, comdat
13 // CHECK: @__tysan_v1_omnipotent_20char = linkonce_odr constant { i64, i64, ptr, i64, [16 x i8] } { i64 2, i64 1, ptr @__tysan_v1_Simple_20C_2b_2b_20TBAA, i64 0, [16 x i8] c"omnipotent char\00" }, comdat
14 // CHECK: @__tysan_v1_int = linkonce_odr constant { i64, i64, ptr, i64, [4 x i8] } { i64 2, i64 1, ptr @__tysan_v1_omnipotent_20char, i64 0, [4 x i8] c"int\00" }, comdat
15 // CHECK: @__tysan_v1_any_20pointer = linkonce_odr constant { i64, i64, ptr, i64, [12 x i8] } { i64 2, i64 1, ptr @__tysan_v1_omnipotent_20char, i64 0, [12 x i8] c"any pointer\00" }, comdat
16 // CHECK: @__tysan_v1_p1_20int = linkonce_odr constant { i64, i64, ptr, i64, [7 x i8] } { i64 2, i64 1, ptr @__tysan_v1_any_20pointer, i64 0, [7 x i8] c"p1 int\00" }, comdat
17 // CHECK: @__tysan_v1___ZTS9CompleteS = linkonce_odr constant { i64, i64, ptr, i64, ptr, i64, [15 x i8] } { i64 2, i64 2, ptr @__tysan_v1_int, i64 0, ptr @__tysan_v1_p1_20int, i64 8, [15 x i8] c"_ZTS9CompleteS\00" }, comdat
18 // CHECK: @__tysan_v1___ZTS1b = linkonce_odr constant { i64, i64, [7 x i8] } { i64 2, i64 0, [7 x i8] c"_ZTS1b\00" }, comdat
19 // CHECK: @llvm.used = appending global [8 x ptr] [ptr @tysan.module_ctor, ptr @__tysan_v1_Simple_20C_2b_2b_20TBAA, ptr @__tysan_v1_omnipotent_20char, ptr @__tysan_v1_int, ptr @__tysan_v1_any_20pointer, ptr @__tysan_v1_p1_20int, ptr @__tysan_v1___ZTS9CompleteS, ptr @__tysan_v1___ZTS1b], section "llvm.metadata"
20 // CHECK: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_sanitize_type_globals.cpp, ptr null }, { i32, ptr, ptr } { i32 0, ptr @tysan.module_ctor, ptr null }]
21 //.
22 struct CompleteS {
23   int x;
24   int *ptr;
25 };
26 
27 void f(CompleteS *);
28 CompleteS x;
29 extern CompleteS xExtern;
30 // CHECK-LABEL: define dso_local void @_Z1gv(
31 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
32 // CHECK:  [[ENTRY:.*:]]
33 // CHECK:    call void @_Z1fP9CompleteS(ptr noundef @x)
34 // CHECK:    call void @_Z1fP9CompleteS(ptr noundef @xExtern)
35 // CHECK:    ret void
36 //
37 void g() {
38   f(&x);
39   f(&xExtern);
40 }
41 
42 typedef struct S IncompleteS;
43 void f(IncompleteS *);
44 extern IncompleteS y;
45 // CHECK-LABEL: define dso_local void @_Z1hv(
46 // CHECK-SAME: ) #[[ATTR0]] {
47 // CHECK:  [[ENTRY:.*:]]
48 // CHECK:    call void @_Z1fP1S(ptr noundef @y)
49 // CHECK:    ret void
50 //
51 void h() { f(&y); }
52 
53 class a;
54 class b {
55 public:
56   using c = a;
57   static c e;
58   b(int, c & = e);
59 } d = 0;
60 
61 //.
62 // CHECK: attributes #[[ATTR0]] = { mustprogress noinline nounwind optnone sanitize_type "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
63 // CHECK: attributes #[[ATTR1:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
64 // CHECK: attributes #[[ATTR2:[0-9]+]] = { noinline nounwind sanitize_type "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
65 // CHECK: attributes #[[ATTR3:[0-9]+]] = { nounwind "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
66 // CHECK: attributes #[[ATTR4:[0-9]+]] = { nounwind }
67 //.
68 // CHECK: [[META0:![0-9]+]] = !{ptr @x, [[META1:![0-9]+]]}
69 // CHECK: [[META1]] = !{!"_ZTS9CompleteS", [[META2:![0-9]+]], i64 0, [[META5:![0-9]+]], i64 8}
70 // CHECK: [[META2]] = !{!"int", [[META3:![0-9]+]], i64 0}
71 // CHECK: [[META3]] = !{!"omnipotent char", [[META4:![0-9]+]], i64 0}
72 // CHECK: [[META4]] = !{!"Simple C++ TBAA"}
73 // CHECK: [[META5]] = !{!"p1 int", [[META6:![0-9]+]], i64 0}
74 // CHECK: [[META6]] = !{!"any pointer", [[META3]], i64 0}
75 // CHECK: [[META7:![0-9]+]] = !{ptr @d, [[META8:![0-9]+]]}
76 // CHECK: [[META8]] = !{!"_ZTS1b"}
77 // CHECK: [[META9:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
78 // CHECK: [[META10:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
79 //.
80