41 lines · cpp
1// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-cir -o %t.cir2// RUN: FileCheck --input-file=%t.cir -check-prefix=CIR %s3// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -fclangir -emit-llvm -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll -check-prefix=LLVM %s5// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o %t.ll6// RUN: FileCheck --input-file=%t.ll -check-prefix=OGCG %s7 8typedef __typeof__(sizeof(0)) size_t;9 10// Declare the reserved placement operators.11void *operator new(size_t, void*) throw();12 13struct A { A(); ~A(); };14 15void test_reserved_placement_new(void *p) {16 new (p) A();17}18 19// CIR-LABEL: cir.func dso_local @_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> : !u64i24// 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 ptr31// 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 ptr38// OGCG: store ptr %[[ARG0:.*]], ptr %[[P]]39// OGCG: %[[PTR:.*]] = load ptr, ptr %[[P]]40// OGCG: call void @_ZN1AC1Ev(ptr {{.*}} %[[PTR]])41