Skip to content

Commit 7c20576

Browse files
ImanHosseiniIman Hosseiniclementval
authored
[flang][cuda] fix parsing of cuda_kernel (llvm#89613)
Fix parsing of cuda_kernel: it missed a mlir::succeeded check and it was not setting up the `types` and causing mismatch between values and types of the grid/block (CUFKernelValues). @clementval --------- Co-authored-by: Iman Hosseini <[email protected]> Co-authored-by: Valentin Clement (バレンタイン クレメン) <[email protected]>
1 parent 8128d4b commit 7c20576

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3907,19 +3907,25 @@ mlir::ParseResult parseCUFKernelValues(
39073907
if (mlir::succeeded(parser.parseOptionalStar()))
39083908
return mlir::success();
39093909

3910-
if (parser.parseOptionalLParen()) {
3910+
if (mlir::succeeded(parser.parseOptionalLParen())) {
39113911
if (mlir::failed(parser.parseCommaSeparatedList(
39123912
mlir::AsmParser::Delimiter::None, [&]() {
39133913
if (parser.parseOperand(values.emplace_back()))
39143914
return mlir::failure();
39153915
return mlir::success();
39163916
})))
39173917
return mlir::failure();
3918+
auto builder = parser.getBuilder();
3919+
for (size_t i = 0; i < values.size(); i++) {
3920+
types.emplace_back(builder.getI32Type());
3921+
}
39183922
if (parser.parseRParen())
39193923
return mlir::failure();
39203924
} else {
39213925
if (parser.parseOperand(values.emplace_back()))
39223926
return mlir::failure();
3927+
auto builder = parser.getBuilder();
3928+
types.emplace_back(builder.getI32Type());
39233929
return mlir::success();
39243930
}
39253931
return mlir::success();

flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
2+
! RUN: bbc -emit-hlfir -fcuda %s -o - | fir-opt | FileCheck %s
23

34
! Test lowering of CUDA kernel loop directive.
45

0 commit comments

Comments
 (0)