diff options
| author | Tobias Grosser <tobias@grosser.es> | 2016-07-28 06:47:53 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2016-07-28 06:47:53 +0000 |
| commit | 44143bb927ce58beabd92adbd4115364a4c093c4 (patch) | |
| tree | 70b77ae97d357683740145b6cb8022e1e91e88ab | |
| parent | 4e18d71c71788654dd5c3e3b151ada8666b91029 (diff) | |
| download | bcm5719-llvm-44143bb927ce58beabd92adbd4115364a4c093c4.tar.gz bcm5719-llvm-44143bb927ce58beabd92adbd4115364a4c093c4.zip | |
GPGPU: use current 'Index' to find slot in parameter array
Before this change we used the array index, which would result in us accessing
the parameter array out-of-bounds. This bug was visible for test cases where not
all arrays in a scop are passed to a given kernel.
llvm-svn: 276961
| -rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 4 | ||||
| -rw-r--r-- | polly/test/GPGPU/kernel-params-only-some-arrays.ll | 15 |
2 files changed, 16 insertions, 3 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index 20ab4999cf7..3a6b80b75a3 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -903,8 +903,8 @@ Value *GPUNodeBuilder::createLaunchParameters(ppcg_kernel *Kernel, Builder.getInt8PtrTy(), Launch + "_param_" + std::to_string(Index), EntryBlock->getTerminator()); Builder.CreateStore(DevArray, Param); - Value *Slot = Builder.CreateGEP(Parameters, - {Builder.getInt64(0), Builder.getInt64(i)}); + Value *Slot = Builder.CreateGEP( + Parameters, {Builder.getInt64(0), Builder.getInt64(Index)}); Value *ParamTyped = Builder.CreatePointerCast(Param, Builder.getInt8PtrTy()); Builder.CreateStore(ParamTyped, Slot); diff --git a/polly/test/GPGPU/kernel-params-only-some-arrays.ll b/polly/test/GPGPU/kernel-params-only-some-arrays.ll index 0d36c54dd8b..5c932b5db1d 100644 --- a/polly/test/GPGPU/kernel-params-only-some-arrays.ll +++ b/polly/test/GPGPU/kernel-params-only-some-arrays.ll @@ -1,7 +1,11 @@ ; RUN: opt %loadPolly -polly-codegen-ppcg -polly-acc-dump-kernel-ir \ ; RUN: -disable-output < %s | \ ; RUN: FileCheck -check-prefix=KERNEL %s -; + +; RUN: opt %loadPolly -polly-codegen-ppcg \ +; RUN: -S < %s | \ +; RUN: FileCheck -check-prefix=IR %s + ; REQUIRES: pollyacc ; ; void kernel_params_only_some_arrays(float A[], float B[]) { @@ -42,6 +46,15 @@ ; KERNEL: ret void ; KERNEL-NEXT: } + +; IR: [[SLOT:%.*]] = getelementptr [1 x i8*], [1 x i8*]* %polly_launch_0_params, i64 0, i64 0 +; IR-NEXT: [[DATA:%.*]] = bitcast i8** %polly_launch_0_param_0 to i8* +; IR-NEXT: store i8* [[DATA]], i8** [[SLOT]] + +; IR: [[SLOT:%.*]] = getelementptr [1 x i8*], [1 x i8*]* %polly_launch_1_params, i64 0, i64 0 +; IR-NEXT: [[DATA:%.*]] = bitcast i8** %polly_launch_1_param_0 to i8* +; IR-NEXT: store i8* [[DATA]], i8** [[SLOT]] + target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" define void @kernel_params_only_some_arrays(float* %A, float* %B) { |

