mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 10:01:42 +00:00
[OPENMP]Add codegen for private vars with allocate clause.
Added codegen/test for the privatized variables with the allocate clause. llvm-svn: 357514
This commit is contained in:
parent
a31347f17d
commit
0fd3c68c1a
@ -9761,13 +9761,9 @@ Address CGOpenMPRuntime::getAddressOfLocalVariable(CodeGenFunction &CGF,
|
||||
return Address::invalid();
|
||||
const auto *AA = CVD->getAttr<OMPAllocateDeclAttr>();
|
||||
// Use the default allocation.
|
||||
if (AA->getAllocatorType() == OMPAllocateDeclAttr::OMPDefaultMemAlloc)
|
||||
if (AA->getAllocatorType() == OMPAllocateDeclAttr::OMPDefaultMemAlloc &&
|
||||
!AA->getAllocator())
|
||||
return Address::invalid();
|
||||
auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
|
||||
if (!Elem.second.ServiceInsertPt)
|
||||
setLocThreadIdInsertPt(CGF);
|
||||
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
|
||||
CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
|
||||
llvm::Value *Size;
|
||||
CharUnits Align = CGM.getContext().getDeclAlign(CVD);
|
||||
if (CVD->getType()->isVariablyModifiedType()) {
|
||||
|
@ -13,6 +13,16 @@
|
||||
// expected-no-diagnostics
|
||||
#ifndef HEADER
|
||||
#define HEADER
|
||||
typedef void **omp_allocator_handle_t;
|
||||
extern const omp_allocator_handle_t omp_default_mem_alloc;
|
||||
extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
|
||||
extern const omp_allocator_handle_t omp_const_mem_alloc;
|
||||
extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
|
||||
extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
|
||||
extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
|
||||
extern const omp_allocator_handle_t omp_pteam_mem_alloc;
|
||||
extern const omp_allocator_handle_t omp_thread_mem_alloc;
|
||||
|
||||
template <class T>
|
||||
struct S {
|
||||
T f;
|
||||
@ -54,7 +64,7 @@ template<typename T>
|
||||
struct SST {
|
||||
T a;
|
||||
SST() : a(T()) {
|
||||
#pragma omp parallel private(a)
|
||||
#pragma omp parallel private(a) allocate(omp_large_cap_mem_alloc:a)
|
||||
#ifdef LAMBDA
|
||||
[&]() {
|
||||
[&]() {
|
||||
@ -343,12 +353,18 @@ int main() {
|
||||
// CHECK: ret
|
||||
|
||||
// CHECK: define internal void [[SST_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SST_TY]]* %{{.+}})
|
||||
// CHECK: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},
|
||||
// CHECK: [[GTID_ADDR_PTR:%.+]] = alloca i32*,
|
||||
// CHECK: [[GTID_ADDR:%.+]] = load i32*, i32** [[GTID_ADDR_PTR]],
|
||||
// CHECK: [[GTID:%.+]] = load i32, i32* [[GTID_ADDR]],
|
||||
// CHECK: [[LARGE_CAP_ALLOC:%.+]] = load i8**, i8*** @omp_large_cap_mem_alloc,
|
||||
// CHECK: [[A_VOID_PTR:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 4, i8** [[LARGE_CAP_ALLOC]])
|
||||
// CHECK: [[A_PRIV:%.+]] = bitcast i8* [[A_VOID_PTR]] to i32*
|
||||
// CHECK: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REF:%.+]],
|
||||
// CHECK-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REF]],
|
||||
// CHECK-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],
|
||||
// CHECK-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1
|
||||
// CHECK-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],
|
||||
// CHECK-NEXT: call void @__kmpc_free(i32 [[GTID]], i8* [[A_VOID_PTR]], i8** [[LARGE_CAP_ALLOC]])
|
||||
// CHECK-NEXT: ret void
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user