[mlir] fix the types used during the generation of the kernel param array
authorTobias Gysi <tobias.gysi@gmail.com>
Wed, 7 Oct 2020 14:18:46 +0000 (16:18 +0200)
committerTobias Gysi <tobias.gysi@gmail.com>
Wed, 7 Oct 2020 14:18:46 +0000 (16:18 +0200)
The patch fixes the types used to access the elements of the kernel parameter structure from a pointer to the structure to a pointer to the actual parameter type.

Reviewed By: csigg

Differential Revision: https://reviews.llvm.org/D88959

mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp

index 56dc7d3..b25c264 100644 (file)
@@ -279,9 +279,9 @@ Value ConvertLaunchFuncOpToGpuRuntimeCallPattern::generateParamsArray(
   for (auto en : llvm::enumerate(arguments)) {
     auto index = builder.create<LLVM::ConstantOp>(
         loc, llvmInt32Type, builder.getI32IntegerAttr(en.index()));
-    auto fieldPtr =
-        builder.create<LLVM::GEPOp>(loc, structType.getPointerTo(), structPtr,
-                                    ArrayRef<Value>{zero, index.getResult()});
+    auto fieldPtr = builder.create<LLVM::GEPOp>(
+        loc, argumentTypes[en.index()].getPointerTo(), structPtr,
+        ArrayRef<Value>{zero, index.getResult()});
     builder.create<LLVM::StoreOp>(loc, en.value(), fieldPtr);
     auto elementPtr = builder.create<LLVM::GEPOp>(loc, llvmPointerPointerType,
                                                   arrayPtr, index.getResult());