@@ -68,14 +68,33 @@ mlir::Value CIRGenFunction::createOpenACCConstantInt(mlir::Location loc,
68
68
CIRGenFunction::OpenACCDataOperandInfo
69
69
CIRGenFunction::getOpenACCDataOperandInfo (const Expr *e) {
70
70
const Expr *curVarExpr = e->IgnoreParenImpCasts ();
71
+ QualType origType =
72
+ curVarExpr->getType ().getNonReferenceType ().getUnqualifiedType ();
73
+ // Array sections are special, and we have to treat them that way.
74
+ if (const auto *section =
75
+ dyn_cast<ArraySectionExpr>(curVarExpr->IgnoreParenImpCasts ()))
76
+ origType = ArraySectionExpr::getBaseOriginalType (section);
71
77
72
78
mlir::Location exprLoc = cgm.getLoc (curVarExpr->getBeginLoc ());
73
79
llvm::SmallVector<mlir::Value> bounds;
80
+ llvm::SmallVector<QualType> boundTypes;
74
81
75
82
std::string exprString;
76
83
llvm::raw_string_ostream os (exprString);
77
84
e->printPretty (os, nullptr , getContext ().getPrintingPolicy ());
78
85
86
+ auto addBoundType = [&](const Expr *e) {
87
+ if (const auto *section = dyn_cast<ArraySectionExpr>(curVarExpr)) {
88
+ QualType baseTy = ArraySectionExpr::getBaseOriginalType (
89
+ section->getBase ()->IgnoreParenImpCasts ());
90
+ boundTypes.push_back (QualType (baseTy->getPointeeOrArrayElementType (), 0 ));
91
+ } else {
92
+ boundTypes.push_back (curVarExpr->getType ());
93
+ }
94
+ };
95
+
96
+ addBoundType (curVarExpr);
97
+
79
98
while (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) {
80
99
mlir::Location boundLoc = cgm.getLoc (curVarExpr->getBeginLoc ());
81
100
mlir::Value lowerBound;
@@ -115,19 +134,28 @@ CIRGenFunction::getOpenACCDataOperandInfo(const Expr *e) {
115
134
116
135
bounds.push_back (createBound (*this , this ->builder , boundLoc, lowerBound,
117
136
upperBound, extent));
137
+ addBoundType (curVarExpr);
118
138
}
119
139
120
140
if (const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr))
121
- return {exprLoc, emitMemberExpr (memExpr).getPointer (), exprString,
141
+ return {exprLoc,
142
+ emitMemberExpr (memExpr).getPointer (),
143
+ exprString,
144
+ origType,
122
145
curVarExpr->getType ().getNonReferenceType ().getUnqualifiedType (),
123
- std::move (bounds)};
146
+ std::move (bounds),
147
+ std::move (boundTypes)};
124
148
125
149
// Sema has made sure that only 4 types of things can get here, array
126
150
// subscript, array section, member expr, or DRE to a var decl (or the
127
151
// former 3 wrapping a var-decl), so we should be able to assume this is
128
152
// right.
129
153
const auto *dre = cast<DeclRefExpr>(curVarExpr);
130
- return {exprLoc, emitDeclRefLValue (dre).getPointer (), exprString,
154
+ return {exprLoc,
155
+ emitDeclRefLValue (dre).getPointer (),
156
+ exprString,
157
+ origType,
131
158
curVarExpr->getType ().getNonReferenceType ().getUnqualifiedType (),
132
- std::move (bounds)};
159
+ std::move (bounds),
160
+ std::move (boundTypes)};
133
161
}
0 commit comments