Skip to content

Commit

Permalink
Test for registration of hyperobject structure members
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxSciurorum committed Jan 2, 2024
1 parent cbf8108 commit 313115c
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions clang/test/Cilk/hyper-member.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// RUN: %clang_cc1 %s -fopencilk -fcxx-exceptions -fexceptions -O1 -verify -S -emit-llvm -disable-llvm-passes -o - | FileCheck %s
// expected-no-diagnostics
extern void id(void *), reduce(void *, void *);
extern int getval(int);

// A structure with an implicit constructor and explicit destructor.
struct three_hyperobjects {
int one = 1;
int _Hyperobject(id, reduce) two = 2;
int l1 = getval(-1);
int _Hyperobject(id, reduce) three = 3;
int l2 = getval(-2);
int _Hyperobject(id, reduce) four = 4;
// CHECK: define linkonce_odr void @_ZN18three_hyperobjectsC2Ev
// CHECK: entry
// CHECK: %one = getelementptr
// CHECK: store i32 1, ptr %one
// CHECK: %two = getelementptr
// CHECK: store i32 2, ptr %two
// CHECK: call void @llvm.reducer.register.i64(ptr %two
// CHECK: %l1 = getelementptr inbounds
// CHECK: %[[L1INIT:.+]] = invoke noundef i32 @_Z6getvali(i32 noundef -1)
// CHECK-NEXT: to label %[[CONT1:.+]] unwind label %[[UNWIND1:.+]]
// CHECK: [[CONT1]]
// CHECK: store i32 %[[L1INIT]], ptr %l1
// CHECK: %three = getelementptr
// CHECK: store i32 3, ptr %three
// CHECK: call void @llvm.reducer.register.i64(ptr %three
// CHECK: %[[L2INIT:.+]] = invoke noundef i32 @_Z6getvali(i32 noundef -2)
// CHECK-NEXT: to label %[[CONT2:.+]] unwind label %[[UNWIND2:.+]]
// CHECK: [[CONT2]]
// CHECK: store i32 %[[L2INIT]], ptr %l2
// CHECK: %four = getelementptr
// CHECK: store i32 4, ptr %four
// CHECK: call void @llvm.reducer.register.i64(ptr %four
// CHECK: ret void
// CHECK: [[UNWIND1]]
// CHECK-NEXT: landingpad
// CHECK-NOT: call void @llvm.reducer.unregister
// CHECK: br label %ehcleanup
// CHECK: [[UNWIND2]]
// CHECK-NEXT: landingpad
// CHECK: call void @llvm.reducer.unregister
// CHECK: br label %ehcleanup
// CHECK: ehcleanup:
// CHECK: call void @llvm.reducer.unregister
// CHECK: resume

// CHECK: define linkonce_odr void @_ZN18three_hyperobjectsD2Ev
// Unregister in order four, three, two. In llvm 16 the IR variables
// have the same names as the fields they address.
// CHECK: call void @llvm.reducer.unregister(ptr %four)
// CHECK: call void @llvm.reducer.unregister(ptr %three)
// CHECK: call void @llvm.reducer.unregister(ptr %two)
// CHECK: ret void
~three_hyperobjects() { }
};

three_hyperobjects s;

0 comments on commit 313115c

Please sign in to comment.