| 1 |
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-cir -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir -check-prefix=CIR %s |
| 3 |
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-llvm -o %t-cir.ll |
| 4 |
// RUN: FileCheck --input-file=%t-cir.ll -check-prefix=LLVM %s |
| 5 |
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll -check-prefix=OGCG %s |
| 7 |
|
| 8 |
typedef __typeof__(sizeof(0)) size_t; |
| 9 |
|
| 10 |
// Declare the reserved placement operators. |
| 11 |
void *operator new(size_t, void*) throw(); |
| 12 |
|
| 13 |
struct A { A(); ~A(); }; |
| 14 |
|
| 15 |
void test_reserved_placement_new(void *p) { |
| 16 |
new (p) A(); |
| 17 |
} |
| 18 |
|
| 19 |
// CIR-LABEL: cir.func {{.*}} @_Z27test_reserved_placement_newPv( |
| 20 |
// CIR-SAME: %[[ARG0:.*]]: !cir.ptr<!void> |
| 21 |
// CIR: %[[P:.*]] = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>, ["p", init] |
| 22 |
// CIR: cir.store %[[ARG0]], %[[P]] : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>> |
| 23 |
// CIR: %[[SIZE:.*]] = cir.const #cir.int<1> : !u64i |
| 24 |
// CIR: %[[PTR:.*]] = cir.load{{.*}} %[[P]] : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void> |
| 25 |
// CIR: %[[PTR_A:.*]] = cir.cast bitcast %[[PTR]] : !cir.ptr<!void> -> !cir.ptr<!rec_A> |
| 26 |
// CIR: cir.call @_ZN1AC1Ev(%[[PTR_A]]) : (!cir.ptr<!rec_A>) -> () |
| 27 |
|
| 28 |
// LLVM-LABEL: define dso_local void @_Z27test_reserved_placement_newPv( |
| 29 |
// LLVM-SAME: ptr %[[ARG0:.*]] |
| 30 |
// LLVM: %[[P:.*]] = alloca ptr |
| 31 |
// LLVM: store ptr %[[ARG0:.*]], ptr %[[P]] |
| 32 |
// LLVM: %[[PTR:.*]] = load ptr, ptr %[[P]] |
| 33 |
// LLVM: call void @_ZN1AC1Ev(ptr %[[PTR]]) |
| 34 |
|
| 35 |
// OGCG-LABEL: define dso_local void @_Z27test_reserved_placement_newPv( |
| 36 |
// OGCG-SAME: ptr {{.*}} %[[ARG0:.*]] |
| 37 |
// OGCG: %[[P:.*]] = alloca ptr |
| 38 |
// OGCG: store ptr %[[ARG0:.*]], ptr %[[P]] |
| 39 |
// OGCG: %[[PTR:.*]] = load ptr, ptr %[[P]] |
| 40 |
// OGCG: call void @_ZN1AC1Ev(ptr {{.*}} %[[PTR]]) |