aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcchen <cchen@cray.com>2020-02-28 14:37:14 -0500
committerAlexey Bataev <a.bataev@hotmail.com>2020-02-28 15:07:32 -0500
commit6ee6fa28a74e9b33475a153f35b169f0c83a6ec6 (patch)
tree3a480a2b071ee81d3b8691f1874c22bf5110c636 /clang/lib/CodeGen/CGOpenMPRuntime.cpp
parent[MLIR] Fixes for BUILD_SHARED_LIBS=on (diff)
downloadllvm-project-6ee6fa28a74e9b33475a153f35b169f0c83a6ec6.tar.gz
llvm-project-6ee6fa28a74e9b33475a153f35b169f0c83a6ec6.tar.bz2
llvm-project-6ee6fa28a74e9b33475a153f35b169f0c83a6ec6.zip
[OpenMP5.0] Allow pointer arithmetic in motion/map clause, by Chi Chun
Chen Summary: Base declaration in pointer arithmetic expression is determined by binary search with type information. Take "int *a, *b; *(a+*b)" as an example, we determine the base by checking the type of LHS and RHS. In this case the type of LHS is "int *", the type of RHS is "int", therefore, we know that we need to visit LHS in order to find base declaration. Reviewers: ABataev, jdoerfert Reviewed By: ABataev Subscribers: guansong, cfe-commits, sandoval, dreachem Tags: #clang Differential Revision: https://reviews.llvm.org/D75077
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp')
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 77a62b1aa1e8..79c2f1b10784 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7614,19 +7614,24 @@ private:
// types.
const auto *OASE =
dyn_cast<OMPArraySectionExpr>(I->getAssociatedExpression());
+ const auto *UO = dyn_cast<UnaryOperator>(I->getAssociatedExpression());
+ const auto *BO = dyn_cast<BinaryOperator>(I->getAssociatedExpression());
bool IsPointer =
(OASE && OMPArraySectionExpr::getBaseOriginalType(OASE)
.getCanonicalType()
->isAnyPointerType()) ||
I->getAssociatedExpression()->getType()->isAnyPointerType();
+ bool IsNonDerefPointer = IsPointer && !UO && !BO;
- if (Next == CE || IsPointer || IsFinalArraySection) {
+ if (Next == CE || IsNonDerefPointer || IsFinalArraySection) {
// If this is not the last component, we expect the pointer to be
// associated with an array expression or member expression.
assert((Next == CE ||
isa<MemberExpr>(Next->getAssociatedExpression()) ||
isa<ArraySubscriptExpr>(Next->getAssociatedExpression()) ||
- isa<OMPArraySectionExpr>(Next->getAssociatedExpression())) &&
+ isa<OMPArraySectionExpr>(Next->getAssociatedExpression()) ||
+ isa<UnaryOperator>(Next->getAssociatedExpression()) ||
+ isa<BinaryOperator>(Next->getAssociatedExpression())) &&
"Unexpected expression");
Address LB = CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
@@ -7742,7 +7747,7 @@ private:
// mapped member. If the parent is "*this", then the value declaration
// is nullptr.
if (EncounteredME) {
- const auto *FD = dyn_cast<FieldDecl>(EncounteredME->getMemberDecl());
+ const auto *FD = cast<FieldDecl>(EncounteredME->getMemberDecl());
unsigned FieldIndex = FD->getFieldIndex();
// Update info about the lowest and highest elements for this struct