[polly] r276961 - GPGPU: use current 'Index' to find slot in parameter array

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 23:47:53 PDT 2016


Author: grosser
Date: Thu Jul 28 01:47:53 2016
New Revision: 276961

URL: http://llvm.org/viewvc/llvm-project?rev=276961&view=rev
Log:
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.

Modified:
    polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
    polly/trunk/test/GPGPU/kernel-params-only-some-arrays.ll

Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=276961&r1=276960&r2=276961&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Thu Jul 28 01:47:53 2016
@@ -903,8 +903,8 @@ Value *GPUNodeBuilder::createLaunchParam
         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);

Modified: polly/trunk/test/GPGPU/kernel-params-only-some-arrays.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/kernel-params-only-some-arrays.ll?rev=276961&r1=276960&r2=276961&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/kernel-params-only-some-arrays.ll (original)
+++ polly/trunk/test/GPGPU/kernel-params-only-some-arrays.ll Thu Jul 28 01:47:53 2016
@@ -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) {




More information about the llvm-commits mailing list