Skip to content

Commit a43fb2b

Browse files
authored
[OpenACC] Fix issue with array-section type generation (#162499)
When an array section bound was in a list of bound-types we improperly generated the list of types of the bounds because getPointeeOrElementType gets the LOWEST level of type (that is, digs through ALL array types to get to the base-est of types) when what we really wanted was 1 layer of pointer/array removed. This patch fixes it and adds a test that showed the problem by re-ordering the existing ones. This wasn't previously obvious by chance, since the 'array-index-only' variants ended up generating the recipe, and not the bounds.
1 parent 8c9c91f commit a43fb2b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenOpenACC.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ CIRGenFunction::getOpenACCDataOperandInfo(const Expr *e) {
8787
if (const auto *section = dyn_cast<ArraySectionExpr>(curVarExpr)) {
8888
QualType baseTy = ArraySectionExpr::getBaseOriginalType(
8989
section->getBase()->IgnoreParenImpCasts());
90-
boundTypes.push_back(QualType(baseTy->getPointeeOrArrayElementType(), 0));
90+
if (auto *at = getContext().getAsArrayType(baseTy))
91+
boundTypes.push_back(at->getElementType());
92+
else
93+
boundTypes.push_back(baseTy->getPointeeType());
9194
} else {
9295
boundTypes.push_back(curVarExpr->getType());
9396
}

clang/test/CIR/CodeGenOpenACC/private-clause-array-recipes-int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void do_things(unsigned A, unsigned B) {
2121
;
2222

2323
T TwoArr[5][5];
24-
#pragma acc parallel private(TwoArr[B][B])
24+
#pragma acc parallel private(TwoArr[A:B][A:B])
2525
// CHECK-NEXT: acc.private.recipe @privatization__Bcnt2__ZTSA5_A5_i : !cir.ptr<!cir.array<!cir.array<!s32i x 5> x 5>> init {
2626
// CHECK-NEXT: ^bb0(%arg0: !cir.ptr<!cir.array<!cir.array<!s32i x 5> x 5>> {{.*}}, %[[BOUND1:.*]]: !acc.data_bounds_ty {{.*}}, %[[BOUND2:.*]]: !acc.data_bounds_ty {{.*}}):
2727
// CHECK-NEXT: %[[TL_ALLOCA:.*]] = cir.alloca !cir.array<!cir.array<!s32i x 5> x 5>, !cir.ptr<!cir.array<!cir.array<!s32i x 5> x 5>>, ["openacc.private.init"] {alignment = 4 : i64}
@@ -30,7 +30,7 @@ void do_things(unsigned A, unsigned B) {
3030
;
3131
#pragma acc parallel private(TwoArr[B][A:B])
3232
;
33-
#pragma acc parallel private(TwoArr[A:B][A:B])
33+
#pragma acc parallel private(TwoArr[B][B])
3434
;
3535
#pragma acc parallel private(TwoArr)
3636
// CHECK-NEXT: acc.private.recipe @privatization__ZTSA5_A5_i : !cir.ptr<!cir.array<!cir.array<!s32i x 5> x 5>> init {

0 commit comments

Comments
 (0)