summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/PPCGCodeGeneration.cpp
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-08-09 15:35:06 +0000
committerTobias Grosser <tobias@grosser.es>2016-08-09 15:35:06 +0000
commitb06ff4574e22bf997aa741bc09fc143c265b1816 (patch)
treea6ee4fa01aaf6cbc134455f2c75c87b565091f50 /polly/lib/CodeGen/PPCGCodeGeneration.cpp
parent750160e2605af4212727e254f863bbbbe0353174 (diff)
downloadbcm5719-llvm-b06ff4574e22bf997aa741bc09fc143c265b1816.tar.gz
bcm5719-llvm-b06ff4574e22bf997aa741bc09fc143c265b1816.zip
[GPGPU] Support PHI nodes used in GPU kernel
Ensure the right scalar allocations are used as the host location of data transfers. For the device code, we clear the allocation cache before device code generation to be able to generate new device-specific allocation and we need to make sure to add back the old host allocations as soon as the device code generation is finished. llvm-svn: 278126
Diffstat (limited to 'polly/lib/CodeGen/PPCGCodeGeneration.cpp')
-rw-r--r--polly/lib/CodeGen/PPCGCodeGeneration.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp
index 32858fc213d..2ca25ab1238 100644
--- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp
+++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp
@@ -722,14 +722,14 @@ void GPUNodeBuilder::createDataTransfer(__isl_take isl_ast_node *TransferStmt,
auto ScopArray = (ScopArrayInfo *)(Array->user);
Value *Size = getArraySize(Array);
- Value *HostPtr = ScopArray->getBasePtr();
-
Value *DevPtr = DeviceAllocations[ScopArray];
- if (gpu_array_is_scalar(Array)) {
- HostPtr = Builder.CreateAlloca(ScopArray->getElementType());
- Builder.CreateStore(ScopArray->getBasePtr(), HostPtr);
- }
+ Value *HostPtr;
+
+ if (gpu_array_is_scalar(Array))
+ HostPtr = BlockGen.getOrCreateAlloca(ScopArray);
+ else
+ HostPtr = ScopArray->getBasePtr();
HostPtr = Builder.CreatePointerCast(HostPtr, Builder.getInt8PtrTy());
@@ -1074,6 +1074,10 @@ void GPUNodeBuilder::createKernel(__isl_take isl_ast_node *KernelStmt) {
Instruction &HostInsertPoint = *Builder.GetInsertPoint();
IslExprBuilder::IDToValueTy HostIDs = IDToValue;
ValueMapT HostValueMap = ValueMap;
+ BlockGenerator::ScalarAllocaMapTy HostScalarMap = ScalarMap;
+ BlockGenerator::ScalarAllocaMapTy HostPHIOpMap = PHIOpMap;
+ ScalarMap.clear();
+ PHIOpMap.clear();
SetVector<const Loop *> Loops;
@@ -1102,9 +1106,9 @@ void GPUNodeBuilder::createKernel(__isl_take isl_ast_node *KernelStmt) {
Builder.SetInsertPoint(&HostInsertPoint);
IDToValue = HostIDs;
- ValueMap = HostValueMap;
- ScalarMap.clear();
- PHIOpMap.clear();
+ ValueMap = std::move(HostValueMap);
+ ScalarMap = std::move(HostScalarMap);
+ PHIOpMap = std::move(HostPHIOpMap);
EscapeMap.clear();
IDToSAI.clear();
Annotator.resetAlternativeAliasBases();
@@ -1283,7 +1287,7 @@ void GPUNodeBuilder::prepareKernelArguments(ppcg_kernel *Kernel, Function *FN) {
continue;
}
- Value *Alloca = BlockGen.getOrCreateScalarAlloca(SAI->getBasePtr());
+ Value *Alloca = BlockGen.getOrCreateAlloca(SAI);
Value *ArgPtr = &*Arg;
Type *TypePtr = SAI->getElementType()->getPointerTo();
Value *TypedArgPtr = Builder.CreatePointerCast(ArgPtr, TypePtr);
OpenPOWER on IntegriCloud