From 47517b7224cb7805008b17d2690458ec9944ccba Mon Sep 17 00:00:00 2001 From: "John F. Carr" Date: Thu, 31 Oct 2024 13:42:57 -0400 Subject: [PATCH] Test for hyperobject fields --- clang/test/Cilk/hyper-member.cpp | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 clang/test/Cilk/hyper-member.cpp diff --git a/clang/test/Cilk/hyper-member.cpp b/clang/test/Cilk/hyper-member.cpp new file mode 100644 index 000000000000..28ccb6b78a19 --- /dev/null +++ b/clang/test/Cilk/hyper-member.cpp @@ -0,0 +1,68 @@ +// RUN: %clang_cc1 %s -x c++ -triple aarch64-freebsd -fopencilk -S -emit-llvm -disable-llvm-passes -o - | FileCheck %s +struct ctor_dtor { ctor_dtor(); ~ctor_dtor(); long data; }; +struct ctor_only { ctor_only(); long data; }; +struct dtor_only { ~dtor_only(); long data; }; +struct neither { long data; }; +extern void identity(void *), reduce(void *, void *); +struct with_ctor_dtor { + with_ctor_dtor(); + ~with_ctor_dtor(); + ctor_dtor _Hyperobject(identity, reduce) field; +}; + +// Hyperobject field is constructed then registered. +// CHECK-LABEL: _ZN14with_ctor_dtorC2Ev +// CHECK: call void @_ZN9ctor_dtorC1Ev +// CHECK: call void @llvm.reducer.register +with_ctor_dtor::with_ctor_dtor() { } + +// Hyperobject field is destructed then unregistered. +// CHECK-LABEL: _ZN14with_ctor_dtorD2Ev +// CHECK: call void @llvm.reducer.unregister +// CHECK: call void @_ZN9ctor_dtorD1Ev +with_ctor_dtor::~with_ctor_dtor() { } + +template struct wrapper { + wrapper(); + ~wrapper(); + Field field; +}; + +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH9ctor_dtorEC2Ev +// CHECK: call void @_ZN9ctor_dtorC1Ev +// CHECK: call void @llvm.reducer.register +template<> wrapper::wrapper() { } +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH9ctor_dtorED2Ev +// CHECK: call void @llvm.reducer.unregister +// CHECK: call void @_ZN9ctor_dtorD1Ev +template<> wrapper::~wrapper() { } + +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH9ctor_onlyEC2Ev +// CHECK: call void @_ZN9ctor_onlyC1Ev +// CHECK: call void @llvm.reducer.register +template<> wrapper::wrapper() { } + +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH9ctor_onlyED2Ev +// CHECK: call void @llvm.reducer.unregister +// CHECK-NOT: call void @_ZN9ctor_onlyD1Ev +template<> wrapper::~wrapper() { } + +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH9dtor_onlyEC2Ev +// CHECK-NOT: call void @_ZN9dtor_onlyC1Ev +// CHECK: call void @llvm.reducer.register +template<> wrapper::wrapper() { } + +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH9dtor_onlyED2Ev +// CHECK: call void @llvm.reducer.unregister +// CHECK: call void @_ZN9dtor_onlyD1Ev +template<> wrapper::~wrapper() { } + +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH7neitherEC2Ev +// CHECK-NOT: call void @_ZN7neitherC1Ev +// CHECK: call void @llvm.reducer.register +template<> wrapper::wrapper() { } + +// CHECK-LABEL: define dso_local void @_ZN7wrapperIH7neitherED2Ev +// CHECK: call void @llvm.reducer.unregister +// CHECK-NOT: call void @_ZN7neitherD1Ev +template<> wrapper::~wrapper() { }