Skip to content

Commit 4791983

Browse files
erichkeanerorth
authored andcommitted
[OpenACC][CIR] Implement member exprs for 'copy' lowering (llvm#142998)
These ended up not being too much of a change, it just requires that we properly emit a member expression,then use it in the varPtr. I also fixed up the 'name' field to be the expression print, as that was necessary to get this correct. Finally, I added a TON of tests to convince myself that I've got this correct, and hopefully the IR shows that.
1 parent 94379d7 commit 4791983

File tree

5 files changed

+1465
-109
lines changed

5 files changed

+1465
-109
lines changed

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include "CIRGenFunction.h"
1616

17+
#include "clang/AST/ExprCXX.h"
18+
1719
#include "mlir/Dialect/Arith/IR/Arith.h"
1820
#include "mlir/Dialect/OpenACC/OpenACC.h"
1921
#include "llvm/ADT/TypeSwitch.h"
@@ -188,7 +190,7 @@ class OpenACCClauseCIREmitter final
188190
struct DataOperandInfo {
189191
mlir::Location beginLoc;
190192
mlir::Value varValue;
191-
llvm::StringRef name;
193+
std::string name;
192194
llvm::SmallVector<mlir::Value> bounds;
193195
};
194196

@@ -226,6 +228,10 @@ class OpenACCClauseCIREmitter final
226228
mlir::Location exprLoc = cgf.cgm.getLoc(curVarExpr->getBeginLoc());
227229
llvm::SmallVector<mlir::Value> bounds;
228230

231+
std::string exprString;
232+
llvm::raw_string_ostream os(exprString);
233+
e->printPretty(os, nullptr, cgf.getContext().getPrintingPolicy());
234+
229235
// Assemble the list of bounds.
230236
while (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) {
231237
mlir::Location boundLoc = cgf.cgm.getLoc(curVarExpr->getBeginLoc());
@@ -267,20 +273,16 @@ class OpenACCClauseCIREmitter final
267273
bounds.push_back(createBound(boundLoc, lowerBound, upperBound, extent));
268274
}
269275

270-
// TODO: OpenACC: if this is a member expr, emit the VarPtrPtr correctly.
271-
if (isa<MemberExpr>(curVarExpr)) {
272-
cgf.cgm.errorNYI(curVarExpr->getSourceRange(),
273-
"OpenACC Data clause member expr");
274-
return {exprLoc, {}, {}, std::move(bounds)};
275-
}
276+
if (const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr))
277+
return {exprLoc, cgf.emitMemberExpr(memExpr).getPointer(), exprString,
278+
std::move(bounds)};
276279

277280
// Sema has made sure that only 4 types of things can get here, array
278281
// subscript, array section, member expr, or DRE to a var decl (or the
279282
// former 3 wrapping a var-decl), so we should be able to assume this is
280283
// right.
281284
const auto *dre = cast<DeclRefExpr>(curVarExpr);
282-
const auto *vd = cast<VarDecl>(dre->getFoundDecl()->getCanonicalDecl());
283-
return {exprLoc, cgf.emitDeclRefLValue(dre).getPointer(), vd->getName(),
285+
return {exprLoc, cgf.emitDeclRefLValue(dre).getPointer(), exprString,
284286
std::move(bounds)};
285287
}
286288

0 commit comments

Comments
 (0)