| 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 --check-prefix=OGCG --input-file=%t.ll %s |
| 8 |
|
| 9 |
struct Foo { |
| 10 |
void m1(int); |
| 11 |
virtual void m2(int); |
| 12 |
virtual void m3(int); |
| 13 |
}; |
| 14 |
|
| 15 |
void unused_pointer_to_member_func(void (Foo::*func)(int)) { |
| 16 |
} |
| 17 |
|
| 18 |
// CIR-BEFORE: cir.func {{.*}} @_Z29unused_pointer_to_member_funcM3FooFviE(%[[ARG:.*]]: !cir.method<!cir.func<(!s32i)> in !rec_Foo>) |
| 19 |
// CIR-BEFORE: %[[FUNC:.*]] = cir.alloca !cir.method<!cir.func<(!s32i)> in !rec_Foo>, !cir.ptr<!cir.method<!cir.func<(!s32i)> in !rec_Foo>>, ["func", init] |
| 20 |
|
| 21 |
// CIR-AFTER: !rec_anon_struct = !cir.record<struct {!s64i, !s64i}> |
| 22 |
// CIR-AFTER: cir.func {{.*}} @_Z29unused_pointer_to_member_funcM3FooFviE(%[[ARG:.*]]: !rec_anon_struct {{.*}}) |
| 23 |
// CIR-AFTER %[[FUNC:.*]] = cir.alloca !rec_anon_struct, !cir.ptr<!rec_anon_struct>, ["func", init] |
| 24 |
|
| 25 |
// NOTE: The difference between LLVM and OGCG are due to the lack of calling convention handling in CIR. |
| 26 |
|
| 27 |
// LLVM: define {{.*}} void @_Z29unused_pointer_to_member_funcM3FooFviE({ i64, i64 } %[[ARG:.*]]) |
| 28 |
// LLVM: %[[FUNC:.*]] = alloca { i64, i64 } |
| 29 |
// LLVM: store { i64, i64 } %[[ARG]], ptr %[[FUNC]] |
| 30 |
|
| 31 |
// OGCG: define {{.*}} void @_Z29unused_pointer_to_member_funcM3FooFviE(i64 %[[FUNC_COERCE0:.*]], i64 %[[FUNC_COERCE1:.*]]) |
| 32 |
// OGCG: %[[FUNC:.*]] = alloca { i64, i64 } |
| 33 |
// OGCG: %[[FUNC_ADDR:.*]] = alloca { i64, i64 } |
| 34 |
// OGCG: %[[FUNC_0:.*]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[FUNC]], i32 0, i32 0 |
| 35 |
// OGCG: store i64 %[[FUNC_COERCE0]], ptr %[[FUNC_0]] |
| 36 |
// OGCG: %[[FUNC_1:.*]] = getelementptr inbounds nuw { i64, i64 }, ptr %[[FUNC]], i32 0, i32 1 |
| 37 |
// OGCG: store i64 %[[FUNC_COERCE1]], ptr %[[FUNC_1]] |
| 38 |
// OGCG: %[[FUNC1:.*]] = load { i64, i64 }, ptr %[[FUNC]] |
| 39 |
// OGCG: store { i64, i64 } %[[FUNC1]], ptr %[[FUNC_ADDR]] |