Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / tbaa-reference.cpp
blobc4d9e70a8b07f3faa30b7a8f50033e57acdfc364
1 // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,OLD-PATH
2 // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -new-struct-path-tbaa -o - | FileCheck %s -check-prefixes=CHECK,NEW-PATH
3 //
4 // Check that we generate correct TBAA information for reference accesses.
6 struct S;
8 struct B {
9 S &s;
10 B(S &s);
11 S &get();
14 B::B(S &s) : s(s) {
15 // CHECK-LABEL: _ZN1BC2ER1S
16 // Check initialization of the reference parameter.
17 // CHECK: store ptr {{.*}}, ptr {{.*}}, !tbaa [[TAG_pointer:!.*]]
19 // Check loading of the reference parameter.
20 // CHECK: load ptr, ptr {{.*}}, !tbaa [[TAG_pointer]]
22 // Check initialization of the reference member.
23 // CHECK: store ptr {{.*}}, ptr {{.*}}, !tbaa [[TAG_pointer]]
26 S &B::get() {
27 // CHECK-LABEL: _ZN1B3getEv
28 // Check that we access the reference as a structure member.
29 // CHECK: load ptr, ptr {{.*}}, !tbaa [[TAG_B_s:!.*]]
30 return s;
33 // OLD-PATH-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0}
34 // OLD-PATH-DAG: [[TAG_B_s]] = !{[[TYPE_B:!.*]], [[TYPE_pointer]], i64 0}
36 // OLD-PATH-DAG: [[TYPE_B]] = !{!"_ZTS1B", [[TYPE_pointer]], i64 0}
37 // OLD-PATH-DAG: [[TYPE_pointer]] = !{!"any pointer", [[TYPE_char:!.*]], i64 0}
38 // OLD-PATH-DAG: [[TYPE_char]] = !{!"omnipotent char", {{!.*}}, i64 0}
40 // NEW-PATH-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0, i64 8}
41 // NEW-PATH-DAG: [[TAG_B_s]] = !{[[TYPE_B:!.*]], [[TYPE_pointer]], i64 0, i64 8}
43 // NEW-PATH-DAG: [[TYPE_B]] = !{[[TYPE_char:!.*]], i64 8, !"_ZTS1B", [[TYPE_pointer]], i64 0, i64 8}
44 // NEW-PATH-DAG: [[TYPE_pointer]] = !{[[TYPE_char:!.*]], i64 8, !"any pointer"}
45 // NEW-PATH-DAG: [[TYPE_char]] = !{{{!.*}}, i64 1, !"omnipotent char"}