Debian Codegraph @

clang/test/CIR/CodeGen/pointer-to-data-member-cmp.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-cir -mmlir -mlir-print-ir-before=cir-cxxabi-lowering %s -o %t.cir 2> %t-before.cir
2 // RUN: FileCheck --check-prefix=CIR-BEFORE --input-file=%t-before.cir %s
3 // RUN: FileCheck --check-prefix=CIR-AFTER --input-file=%t.cir %s
4 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-llvm %s -o %t-cir.ll
5 // RUN: FileCheck --input-file=%t-cir.ll --check-prefix=LLVM %s
6 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -emit-llvm %s -o %t.ll
7 // RUN: FileCheck --input-file=%t.ll --check-prefix=OGCG %s
8
9 struct Foo {
10 int a;
11 };
12
13 struct Bar {
14 int a;
15 };
16
17 bool eq(int Foo::*x, int Foo::*y) {
18 return x == y;
19 }
20
21 // CIR-BEFORE-LABEL: @_Z2eqM3FooiS0_
22 // CIR-BEFORE: %[[#x:]] = cir.load{{.*}} %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !rec_Foo>>, !cir.data_member<!s32i in !rec_Foo>
23 // CIR-BEFORE-NEXT: %[[#y:]] = cir.load{{.*}} %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !rec_Foo>>, !cir.data_member<!s32i in !rec_Foo>
24 // CIR-BEFORE-NEXT: %{{.+}} = cir.cmp(eq, %[[#x]], %[[#y]]) : !cir.data_member<!s32i in !rec_Foo>, !cir.bool
25 // CIR-BEFORE: }
26
27 // CIR-AFTER-LABEL: @_Z2eqM3FooiS0_
28 // CIR-AFTER: %[[#x:]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!s64i>, !s64i
29 // CIR-AFTER: %[[#y:]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!s64i>, !s64i
30 // CIR-AFTER: %{{.*}} = cir.cmp(eq, %[[#x]], %[[#y]]) : !s64i, !cir.bool
31
32 // LLVM-LABEL: @_Z2eqM3FooiS0_
33 // LLVM: %[[#x:]] = load i64, ptr %{{.+}}, align 8
34 // LLVM-NEXT: %[[#y:]] = load i64, ptr %{{.+}}, align 8
35 // LLVM-NEXT: %{{.+}} = icmp eq i64 %[[#x]], %[[#y]]
36 // LLVM: }
37
38 // OGCG-LABEL: @_Z2eqM3FooiS0_
39 // OGCG: %[[#x:]] = load i64, ptr %{{.+}}, align 8
40 // OGCG-NEXT: %[[#y:]] = load i64, ptr %{{.+}}, align 8
41 // OGCG-NEXT: %{{.+}} = icmp eq i64 %[[#x]], %[[#y]]
42 // OGCG: }
43
44 bool ne(int Foo::*x, int Foo::*y) {
45 return x != y;
46 }
47
48 // CIR-BEFORE-LABEL: @_Z2neM3FooiS0_
49 // CIR-BEFORE: %[[#x:]] = cir.load{{.*}} %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !rec_Foo>>, !cir.data_member<!s32i in !rec_Foo>
50 // CIR-BEFORE-NEXT: %[[#y:]] = cir.load{{.*}} %{{.+}} : !cir.ptr<!cir.data_member<!s32i in !rec_Foo>>, !cir.data_member<!s32i in !rec_Foo>
51 // CIR-BEFORE-NEXT: %{{.+}} = cir.cmp(ne, %[[#x]], %[[#y]]) : !cir.data_member<!s32i in !rec_Foo>, !cir.bool
52 // CIR-BEFORE: }
53
54 // CIR-AFTER-LABEL: @_Z2neM3FooiS0_
55 // CIR-AFTER: %[[#x:]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!s64i>, !s64i
56 // CIR-AFTER: %[[#y:]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!s64i>, !s64i
57 // CIR-AFTER: %{{.*}} = cir.cmp(ne, %[[#x]], %[[#y]]) : !s64i, !cir.bool
58
59 // LLVM-LABEL: @_Z2neM3FooiS0_
60 // LLVM: %[[#x:]] = load i64, ptr %{{.+}}, align 8
61 // LLVM-NEXT: %[[#y:]] = load i64, ptr %{{.+}}, align 8
62 // LLVM-NEXT: %{{.+}} = icmp ne i64 %[[#x]], %[[#y]]
63 // LLVM: }
64
65 // OGCG-LABEL: @_Z2neM3FooiS0_
66 // OGCG: %[[#x:]] = load i64, ptr %{{.+}}, align 8
67 // OGCG-NEXT: %[[#y:]] = load i64, ptr %{{.+}}, align 8
68 // OGCG-NEXT: %{{.+}} = icmp ne i64 %[[#x]], %[[#y]]
69 // OGCG: }