This revision was automatically updated to reflect the committed changes.
Closed by commit rGec66ed79f43c: [OpenMP] Correctly add member expressions to
OpenMP info (authored by jhuber6).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108483/new/
https://reviews.llvm.org/D108483
Files:
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_map_names.cpp
Index: clang/test/OpenMP/target_map_names.cpp
===================================================================
--- clang/test/OpenMP/target_map_names.cpp
+++ clang/test/OpenMP/target_map_names.cpp
@@ -166,6 +166,10 @@
}
struct S3 {
+ S3() {
+#pragma omp target data map(alloc : Z[0:64])
+ { }
+ }
double Z[64];
};
@@ -177,7 +181,10 @@
{ }
}
+
+
// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] c";s.Z[0:64];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
+// DEBUG: @{{[0-9]+}} = private unnamed_addr constant [{{[0-9]+}} x i8] c";this->Z[0:64];{{.*}}.cpp;{{[0-9]+}};{{[0-9]+}};;\00"
// Clang used to mistakenly generate the map name "x" for both x and y on this
// directive. Conditions to reproduce the bug: a single map clause has two
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9435,34 +9435,50 @@
}
}
+// Try to extract the base declaration from a `this->x` expression if possible.
+static ValueDecl *getDeclFromThisExpr(const Expr *E) {
+ if (!E)
+ return nullptr;
+
+ if (const auto *OASE = dyn_cast<OMPArraySectionExpr>(E->IgnoreParenCasts()))
+ if (const MemberExpr *ME =
+ dyn_cast<MemberExpr>(OASE->getBase()->IgnoreParenImpCasts()))
+ return ME->getMemberDecl();
+ return nullptr;
+}
+
/// Emit a string constant containing the names of the values mapped to the
/// offloading runtime library.
llvm::Constant *
emitMappingInformation(CodeGenFunction &CGF, llvm::OpenMPIRBuilder &OMPBuilder,
MappableExprsHandler::MappingExprInfo &MapExprs) {
- llvm::Constant *SrcLocStr;
- if (!MapExprs.getMapDecl()) {
- SrcLocStr = OMPBuilder.getOrCreateDefaultSrcLocStr();
+
+ if (!MapExprs.getMapDecl() && !MapExprs.getMapExpr())
+ return OMPBuilder.getOrCreateDefaultSrcLocStr();
+
+ SourceLocation Loc;
+ if (!MapExprs.getMapDecl() && MapExprs.getMapExpr()) {
+ if (const ValueDecl *VD = getDeclFromThisExpr(MapExprs.getMapExpr()))
+ Loc = VD->getLocation();
+ else
+ Loc = MapExprs.getMapExpr()->getExprLoc();
} else {
- std::string ExprName = "";
- if (MapExprs.getMapExpr()) {
- PrintingPolicy P(CGF.getContext().getLangOpts());
- llvm::raw_string_ostream OS(ExprName);
- MapExprs.getMapExpr()->printPretty(OS, nullptr, P);
- OS.flush();
- } else {
- ExprName = MapExprs.getMapDecl()->getNameAsString();
- }
+ Loc = MapExprs.getMapDecl()->getLocation();
+ }
- SourceLocation Loc = MapExprs.getMapDecl()->getLocation();
- PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
- const char *FileName = PLoc.getFilename();
- unsigned Line = PLoc.getLine();
- unsigned Column = PLoc.getColumn();
- SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FileName, ExprName.c_str(),
- Line, Column);
+ std::string ExprName = "";
+ if (MapExprs.getMapExpr()) {
+ PrintingPolicy P(CGF.getContext().getLangOpts());
+ llvm::raw_string_ostream OS(ExprName);
+ MapExprs.getMapExpr()->printPretty(OS, nullptr, P);
+ OS.flush();
+ } else {
+ ExprName = MapExprs.getMapDecl()->getNameAsString();
}
- return SrcLocStr;
+
+ PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
+ return OMPBuilder.getOrCreateSrcLocStr(PLoc.getFilename(), ExprName.c_str(),
+ PLoc.getLine(), PLoc.getColumn());
}
/// Emit the arrays used to pass the captures and map information to the
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits