summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-04-02 16:03:40 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2019-04-02 16:03:40 +0000
commitc2b831fe1b551b78ec1c392f0a3d15a3351c1b8e (patch)
tree8984af06ede08504475a5b3f48f55203a2485928 /clang/lib/CodeGen
parent7c16c5b6aec53ae59c5c611af55d089a84ed3f10 (diff)
downloadbcm5719-llvm-c2b831fe1b551b78ec1c392f0a3d15a3351c1b8e.tar.gz
bcm5719-llvm-c2b831fe1b551b78ec1c392f0a3d15a3351c1b8e.zip
[OPENMP]Fix mapping of the pointers captured by reference.
If the pointer is captured by reference, it must be mapped as _PTR_AND_OBJ kind of mapping to correctly translate the pointer address on the device. llvm-svn: 357488
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a8af23b63ac..8e23dcd2d20 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7347,6 +7347,9 @@ private:
Cap.getCaptureKind() == CapturedStmt::VCK_ByRef)
return MappableExprsHandler::OMP_MAP_ALWAYS |
MappableExprsHandler::OMP_MAP_TO;
+ if (Cap.getCapturedVar()->getType()->isAnyPointerType())
+ return MappableExprsHandler::OMP_MAP_TO |
+ MappableExprsHandler::OMP_MAP_PTR_AND_OBJ;
return MappableExprsHandler::OMP_MAP_PRIVATE |
MappableExprsHandler::OMP_MAP_TO;
}
@@ -7992,14 +7995,20 @@ public:
CGF.Builder.CreateMemCpy(
CGF.MakeNaturalAlignAddrLValue(Addr, ElementType).getAddress(),
Address(CV, CGF.getContext().getTypeAlignInChars(ElementType)),
- CurSizes.back(),
- /*isVolatile=*/false);
+ CurSizes.back(), /*isVolatile=*/false);
// Use new global variable as the base pointers.
CurBasePointers.push_back(Addr);
CurPointers.push_back(Addr);
} else {
CurBasePointers.push_back(CV);
- CurPointers.push_back(CV);
+ if (FirstPrivateDecls.count(VD) && ElementType->isAnyPointerType()) {
+ Address PtrAddr = CGF.EmitLoadOfReference(CGF.MakeAddrLValue(
+ CV, ElementType, CGF.getContext().getDeclAlign(VD),
+ AlignmentSource::Decl));
+ CurPointers.push_back(PtrAddr.getPointer());
+ } else {
+ CurPointers.push_back(CV);
+ }
}
}
// Every default map produces a single argument which is a target parameter.
OpenPOWER on IntegriCloud