Skip to content

Commit 0d91e6d

Browse files
authored
[OpenACC][CIR] Generate private recipe pointer/array 'alloca's (#160911)
As a next step to generating pointer/array recipes, this patch generates just the 'alloca' lines that are necessary. Copying pointers over to restore the structure is held off to the next patch. In the case of a pointer, we need to allocate the level 'below' it (if we index into it), then copy the values into the pointers. In the case of an array, we skip the alloca (since the array's alloca contains the value). After this, we'll need a patch that copies the pointers into place, and finally one that does the initialization of these values.
1 parent 0d2b404 commit 0d91e6d

16 files changed

+840
-25
lines changed

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
243243
return cir::AllocaOp::create(*this, loc, addrType, type, name, alignment);
244244
}
245245

246+
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType,
247+
mlir::Type type, llvm::StringRef name,
248+
clang::CharUnits alignment) {
249+
mlir::IntegerAttr alignmentAttr = getAlignmentAttr(alignment);
250+
return createAlloca(loc, addrType, type, name, alignmentAttr);
251+
}
252+
246253
/// Get constant address of a global variable as an MLIR attribute.
247254
/// This wrapper infers the attribute type through the global op.
248255
cir::GlobalViewAttr getGlobalViewAttr(cir::GlobalOp globalOp,

clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include <numeric>
14+
1315
#include "CIRGenOpenACCRecipe.h"
1416

1517
namespace clang::CIRGen {
@@ -35,6 +37,110 @@ mlir::Block *OpenACCRecipeBuilderBase::createRecipeBlock(mlir::Region &region,
3537
return builder.createBlock(&region, region.end(), types, locs);
3638
}
3739

40+
mlir::Value OpenACCRecipeBuilderBase::makeBoundsAlloca(
41+
mlir::Block *block, SourceRange exprRange, mlir::Location loc,
42+
std::string_view allocaName, size_t numBounds,
43+
llvm::ArrayRef<QualType> boundTypes) {
44+
mlir::OpBuilder::InsertionGuard guardCase(builder);
45+
46+
// Get the range of bounds arguments, which are all but the 1st arg.
47+
llvm::ArrayRef<mlir::BlockArgument> boundsRange =
48+
block->getArguments().drop_front(1);
49+
50+
// boundTypes contains the before and after of each bounds, so it ends up
51+
// having 1 extra. Assert this is the case to ensure we don't call this in the
52+
// wrong 'block'.
53+
assert(boundsRange.size() + 1 == boundTypes.size());
54+
55+
mlir::Type itrTy = cgf.cgm.convertType(cgf.getContext().UnsignedLongLongTy);
56+
auto idxType = mlir::IndexType::get(&cgf.getMLIRContext());
57+
58+
auto getUpperBound = [&](mlir::Value bound) {
59+
auto upperBoundVal =
60+
mlir::acc::GetUpperboundOp::create(builder, loc, idxType, bound);
61+
return mlir::UnrealizedConversionCastOp::create(builder, loc, itrTy,
62+
upperBoundVal.getResult())
63+
.getResult(0);
64+
};
65+
66+
auto isArrayTy = [&](QualType ty) {
67+
if (ty->isArrayType() && !ty->isConstantArrayType())
68+
cgf.cgm.errorNYI(exprRange, "OpenACC recipe init for VLAs");
69+
return ty->isConstantArrayType();
70+
};
71+
72+
mlir::Type topLevelTy = cgf.convertType(boundTypes.back());
73+
cir::PointerType topLevelTyPtr = builder.getPointerTo(topLevelTy);
74+
// Do an alloca for the 'top' level type without bounds.
75+
mlir::Value initialAlloca = builder.createAlloca(
76+
loc, topLevelTyPtr, topLevelTy, allocaName,
77+
cgf.getContext().getTypeAlignInChars(boundTypes.back()));
78+
79+
bool lastBoundWasArray = isArrayTy(boundTypes.back());
80+
81+
// Since we're iterating the types in reverse, this sets up for each index
82+
// corresponding to the boundsRange to be the 'after application of the
83+
// bounds.
84+
llvm::ArrayRef<QualType> boundResults = boundTypes.drop_back(1);
85+
86+
// Collect the 'do we have any allocas needed after this type' list.
87+
llvm::SmallVector<bool> allocasLeftArr;
88+
llvm::ArrayRef<QualType> resultTypes = boundTypes.drop_front();
89+
std::transform_inclusive_scan(
90+
resultTypes.begin(), resultTypes.end(),
91+
std::back_inserter(allocasLeftArr), std::plus<bool>{},
92+
[](QualType ty) { return !ty->isConstantArrayType(); });
93+
94+
// Keep track of the number of 'elements' that we're allocating. Individual
95+
// allocas should multiply this by the size of its current allocation.
96+
mlir::Value cumulativeElts;
97+
for (auto [bound, resultType, allocasLeft] : llvm::reverse(
98+
llvm::zip_equal(boundsRange, boundResults, allocasLeftArr))) {
99+
100+
// if there is no further 'alloca' operation we need to do, we can skip
101+
// creating the UB/multiplications/etc.
102+
if (!allocasLeft)
103+
break;
104+
105+
// First: figure out the number of elements in the current 'bound' list.
106+
mlir::Value eltsPerSubArray = getUpperBound(bound);
107+
mlir::Value eltsToAlloca;
108+
109+
// IF we are in a sub-bounds, the total number of elements to alloca is
110+
// the product of that one and the current 'bounds' size. That is,
111+
// arr[5][5], we would need 25 elements, not just 5. Else it is just the
112+
// current number of elements.
113+
if (cumulativeElts)
114+
eltsToAlloca = builder.createMul(loc, eltsPerSubArray, cumulativeElts);
115+
else
116+
eltsToAlloca = eltsPerSubArray;
117+
118+
if (!lastBoundWasArray) {
119+
// If we have to do an allocation, figure out the size of the
120+
// allocation. alloca takes the number of bytes, not elements.
121+
TypeInfoChars eltInfo = cgf.getContext().getTypeInfoInChars(resultType);
122+
cir::ConstantOp eltSize = builder.getConstInt(
123+
loc, itrTy, eltInfo.Width.alignTo(eltInfo.Align).getQuantity());
124+
mlir::Value curSize = builder.createMul(loc, eltsToAlloca, eltSize);
125+
126+
mlir::Type eltTy = cgf.convertType(resultType);
127+
cir::PointerType ptrTy = builder.getPointerTo(eltTy);
128+
builder.createAlloca(loc, ptrTy, eltTy, "openacc.init.bounds",
129+
cgf.getContext().getTypeAlignInChars(resultType),
130+
curSize);
131+
132+
// TODO: OpenACC : At this point we should be copying the addresses of
133+
// each element of this to the last allocation. At the moment, that is
134+
// not yet implemented.
135+
cgf.cgm.errorNYI(exprRange, "OpenACC recipe alloca copying");
136+
}
137+
138+
cumulativeElts = eltsToAlloca;
139+
lastBoundWasArray = isArrayTy(resultType);
140+
}
141+
return initialAlloca;
142+
}
143+
38144
mlir::Value
39145
OpenACCRecipeBuilderBase::createBoundsLoop(mlir::Value subscriptedValue,
40146
mlir::Value bound,
@@ -258,7 +364,11 @@ void OpenACCRecipeBuilderBase::createPrivateInitRecipe(
258364
cgf.emitAutoVarAlloca(*allocaDecl, builder.saveInsertionPoint());
259365
cgf.emitAutoVarInit(tempDeclEmission);
260366
} else {
261-
cgf.cgm.errorNYI(exprRange, "private-init with bounds");
367+
makeBoundsAlloca(block, exprRange, loc, "openacc.private.init", numBounds,
368+
boundTypes);
369+
370+
if (initExpr)
371+
cgf.cgm.errorNYI(exprRange, "private-init with bounds initialization");
262372
}
263373

264374
mlir::acc::YieldOp::create(builder, locEnd);

clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424

2525
namespace clang::CIRGen {
2626
class OpenACCRecipeBuilderBase {
27+
// This function generates the required alloca, similar to
28+
// 'emitAutoVarAlloca', except for the OpenACC array/pointer types.
29+
mlir::Value makeBoundsAlloca(mlir::Block *block, SourceRange exprRange,
30+
mlir::Location loc, std::string_view allocaName,
31+
size_t numBounds,
32+
llvm::ArrayRef<QualType> boundTypes);
33+
2734
protected:
2835
CIRGen::CIRGenFunction &cgf;
2936
CIRGen::CIRGenBuilderTy &builder;
@@ -165,28 +172,9 @@ class OpenACCRecipeBuilder : OpenACCRecipeBuilderBase {
165172
cgf.emitAutoVarAlloca(*varRecipe, builder.saveInsertionPoint());
166173

167174
// 'firstprivate' doesn't do its initialization in the 'init' section,
168-
// instead does it in the 'copy' section. SO only do init here.
169-
// 'reduction' appears to use it too (rather than a 'copy' section), so
170-
// we probably have to do it here too, but we can do that when we get to
171-
// reduction implementation.
172-
if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
173-
// We are OK with no init for builtins, arrays of builtins, or pointers,
174-
// else we should NYI so we know to go look for these.
175-
if (cgf.getContext().getLangOpts().CPlusPlus &&
176-
!varRecipe->getType()
177-
->getPointeeOrArrayElementType()
178-
->isBuiltinType() &&
179-
!varRecipe->getType()->isPointerType() && !varRecipe->getInit()) {
180-
// If we don't have any initialization recipe, we failed during Sema to
181-
// initialize this correctly. If we disable the
182-
// Sema::TentativeAnalysisScopes in SemaOpenACC::CreateInitRecipe, it'll
183-
// emit an error to tell us. However, emitting those errors during
184-
// production is a violation of the standard, so we cannot do them.
185-
cgf.cgm.errorNYI(exprRange, "private default-init recipe");
186-
}
187-
cgf.emitAutoVarInit(tempDeclEmission);
188-
} else if constexpr (std::is_same_v<RecipeTy,
189-
mlir::acc::ReductionRecipeOp>) {
175+
// instead it does it in the 'copy' section. SO, only do 'init' here for
176+
// reduction.
177+
if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
190178
// Unlike Private, the recipe here is always required as it has to do
191179
// init, not just 'default' init.
192180
if (!varRecipe->getInit())

clang/test/CIR/CodeGenOpenACC/combined-private-clause.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,47 @@ struct HasDtor {
6565
// int[5] with 1 'bound'
6666
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_i : !cir.ptr<!cir.array<!s32i x 5>> init {
6767
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!s32i x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
68+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!s32i x 5>, !cir.ptr<!cir.array<!s32i x 5>>, ["openacc.private.init"]
6869
// TODO: Add Init here.
6970
// CHECK-NEXT: acc.yield
7071
// CHECK-NEXT: }
7172
//
7273
// float[5] with 1 'bound'
7374
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_f : !cir.ptr<!cir.array<!cir.float x 5>> init {
7475
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!cir.float x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
76+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!cir.float x 5>, !cir.ptr<!cir.array<!cir.float x 5>>, ["openacc.private.init"]
7577
// TODO: Add Init here.
7678
// CHECK-NEXT: acc.yield
7779
// CHECK-NEXT: }
7880
//
7981
// NoCopyConstruct[5] with 1 'bound'
8082
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_15NoCopyConstruct : !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> init {
8183
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
84+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NoCopyConstruct x 5>, !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>>, ["openacc.private.init"]
8285
// TODO: Add Init here.
8386
// CHECK-NEXT: acc.yield
8487
// CHECK-NEXT: }
8588
//
8689
// CopyConstruct[5] with 1 'bound'
8790
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_13CopyConstruct : !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> init {
8891
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
92+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_CopyConstruct x 5>, !cir.ptr<!cir.array<!rec_CopyConstruct x 5>>, ["openacc.private.init"]
8993
// TODO: Add Init here.
9094
// CHECK-NEXT: acc.yield
9195
// CHECK-NEXT: }
9296
//
9397
// NonDefaultCtor[5] with 1 'bound'
9498
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_14NonDefaultCtor : !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> init {
9599
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
100+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NonDefaultCtor x 5>, !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>>, ["openacc.private.init"]
96101
// TODO: Add Init here.
97102
// CHECK-NEXT: acc.yield
98103
// CHECK-NEXT: }
99104
//
100105
// HasDtor[5] with 1 'bound'
101106
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_7HasDtor : !cir.ptr<!cir.array<!rec_HasDtor x 5>> init {
102107
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_HasDtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
108+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_HasDtor x 5>, !cir.ptr<!cir.array<!rec_HasDtor x 5>>, ["openacc.private.init"]
103109
// TODO: Add Init here.
104110
// CHECK-NEXT: acc.yield
105111
// CHECK-NEXT: } destroy {

clang/test/CIR/CodeGenOpenACC/compute-private-clause.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not %clang_cc1 -fopenacc -triple x86_64-linux-gnu -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir -triple x86_64-linux-pc %s -o - | FileCheck %s
1+
// RUN: %clang_cc1 -fopenacc -triple x86_64-linux-gnu -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir -triple x86_64-linux-pc %s -o - | FileCheck %s
22

33
struct NoCopyConstruct {};
44

@@ -26,20 +26,23 @@ struct NoCopyConstruct {};
2626
// int[5] with 1 'bound'
2727
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_i : !cir.ptr<!cir.array<!s32i x 5>> init {
2828
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!s32i x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
29+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!s32i x 5>, !cir.ptr<!cir.array<!s32i x 5>>, ["openacc.private.init"]
2930
// TODO: Add Init here.
3031
// CHECK-NEXT: acc.yield
3132
// CHECK-NEXT: }
3233
//
3334
// float[5] with 1 'bound'
3435
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_f : !cir.ptr<!cir.array<!cir.float x 5>> init {
3536
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!cir.float x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
37+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!cir.float x 5>, !cir.ptr<!cir.array<!cir.float x 5>>, ["openacc.private.init"]
3638
// TODO: Add Init here.
3739
// CHECK-NEXT: acc.yield
3840
// CHECK-NEXT: }
3941
//
4042
// NoCopyConstruct[5] with 1 'bound'
4143
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_15NoCopyConstruct : !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> init {
4244
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
45+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NoCopyConstruct x 5>, !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>>, ["openacc.private.init"]
4346
// TODO: Add Init here.
4447
// CHECK-NEXT: acc.yield
4548
// CHECK-NEXT: }

clang/test/CIR/CodeGenOpenACC/compute-private-clause.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,42 @@ struct HasDtor {
5858
//
5959
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_i : !cir.ptr<!cir.array<!s32i x 5>> init {
6060
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!s32i x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
61+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!s32i x 5>, !cir.ptr<!cir.array<!s32i x 5>>, ["openacc.private.init"]
6162
// TODO: Add Init here.
6263
// CHECK-NEXT: acc.yield
6364
// CHECK-NEXT: }
6465
//
6566
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_f : !cir.ptr<!cir.array<!cir.float x 5>> init {
6667
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!cir.float x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
68+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!cir.float x 5>, !cir.ptr<!cir.array<!cir.float x 5>>, ["openacc.private.init"]
6769
// TODO: Add Init here.
6870
// CHECK-NEXT: acc.yield
6971
// CHECK-NEXT: }
7072
//
7173
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_15NoCopyConstruct : !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> init {
7274
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
75+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NoCopyConstruct x 5>, !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>>, ["openacc.private.init"]
7376
// TODO: Add Init here.
7477
// CHECK-NEXT: acc.yield
7578
// CHECK-NEXT: }
7679
//
7780
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_13CopyConstruct : !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> init {
7881
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
82+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_CopyConstruct x 5>, !cir.ptr<!cir.array<!rec_CopyConstruct x 5>>, ["openacc.private.init"]
7983
// TODO: Add Init here.
8084
// CHECK-NEXT: acc.yield
8185
// CHECK-NEXT: }
8286
//
8387
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_14NonDefaultCtor : !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> init {
8488
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
89+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NonDefaultCtor x 5>, !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>>, ["openacc.private.init"]
8590
// TODO: Add Init here.
8691
// CHECK-NEXT: acc.yield
8792
// CHECK-NEXT: }
8893
//
8994
// CHECK: acc.private.recipe @privatization__Bcnt1__ZTSA5_7HasDtor : !cir.ptr<!cir.array<!rec_HasDtor x 5>> init {
9095
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_HasDtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
96+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_HasDtor x 5>, !cir.ptr<!cir.array<!rec_HasDtor x 5>>, ["openacc.private.init"]
9197
// TODO: Add Init here.
9298
// CHECK-NEXT: acc.yield
9399
// CHECK-NEXT: } destroy {

clang/test/CIR/CodeGenOpenACC/loop-private-clause.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,47 @@ struct HasDtor {
6565
// int[5] with 1 'bound'
6666
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_i : !cir.ptr<!cir.array<!s32i x 5>> init {
6767
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!s32i x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
68+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!s32i x 5>, !cir.ptr<!cir.array<!s32i x 5>>, ["openacc.private.init"]
6869
// TODO: Add Init here.
6970
// CHECK-NEXT: acc.yield
7071
// CHECK-NEXT: }
7172
//
7273
// float[5] with 1 'bound'
7374
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_f : !cir.ptr<!cir.array<!cir.float x 5>> init {
7475
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!cir.float x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
76+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!cir.float x 5>, !cir.ptr<!cir.array<!cir.float x 5>>, ["openacc.private.init"]
7577
// TODO: Add Init here.
7678
// CHECK-NEXT: acc.yield
7779
// CHECK-NEXT: }
7880
//
7981
// NoCopyConstruct[5] with 1 'bound'
8082
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_15NoCopyConstruct : !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> init {
8183
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
84+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NoCopyConstruct x 5>, !cir.ptr<!cir.array<!rec_NoCopyConstruct x 5>>, ["openacc.private.init"]
8285
// TODO: Add Init here.
8386
// CHECK-NEXT: acc.yield
8487
// CHECK-NEXT: }
8588
//
8689
// CopyConstruct[5] with 1 'bound'
8790
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_13CopyConstruct : !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> init {
8891
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_CopyConstruct x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
92+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_CopyConstruct x 5>, !cir.ptr<!cir.array<!rec_CopyConstruct x 5>>, ["openacc.private.init"]
8993
// TODO: Add Init here.
9094
// CHECK-NEXT: acc.yield
9195
// CHECK-NEXT: }
9296
//
9397
// NonDefaultCtor[5] with 1 'bound'
9498
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_14NonDefaultCtor : !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> init {
9599
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
100+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_NonDefaultCtor x 5>, !cir.ptr<!cir.array<!rec_NonDefaultCtor x 5>>, ["openacc.private.init"]
96101
// TODO: Add Init here.
97102
// CHECK-NEXT: acc.yield
98103
// CHECK-NEXT: }
99104
//
100105
// HasDtor[5] with 1 'bound'
101106
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt1__ZTSA5_7HasDtor : !cir.ptr<!cir.array<!rec_HasDtor x 5>> init {
102107
// CHECK-NEXT: ^bb0(%[[ARG:.*]]: !cir.ptr<!cir.array<!rec_HasDtor x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}):
108+
// CHECK-NEXT: %[[ALLOCA:.*]] = cir.alloca !cir.array<!rec_HasDtor x 5>, !cir.ptr<!cir.array<!rec_HasDtor x 5>>, ["openacc.private.init"]
103109
// TODO: Add Init here.
104110
// CHECK-NEXT: acc.yield
105111
// CHECK-NEXT: } destroy {

0 commit comments

Comments
 (0)