[flang][cuda] fix parsing of cuda_kernel (#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 <imanh@nvidia.com>
Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>
This commit is contained in:
Iman Hosseini 2024-04-22 18:16:59 +01:00 committed by GitHub
parent 8128d4b122
commit 7c20576cc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -3907,7 +3907,7 @@ mlir::ParseResult parseCUFKernelValues(
if (mlir::succeeded(parser.parseOptionalStar()))
return mlir::success();
if (parser.parseOptionalLParen()) {
if (mlir::succeeded(parser.parseOptionalLParen())) {
if (mlir::failed(parser.parseCommaSeparatedList(
mlir::AsmParser::Delimiter::None, [&]() {
if (parser.parseOperand(values.emplace_back()))
@ -3915,11 +3915,17 @@ mlir::ParseResult parseCUFKernelValues(
return mlir::success();
})))
return mlir::failure();
auto builder = parser.getBuilder();
for (size_t i = 0; i < values.size(); i++) {
types.emplace_back(builder.getI32Type());
}
if (parser.parseRParen())
return mlir::failure();
} else {
if (parser.parseOperand(values.emplace_back()))
return mlir::failure();
auto builder = parser.getBuilder();
types.emplace_back(builder.getI32Type());
return mlir::success();
}
return mlir::success();

View File

@ -1,4 +1,5 @@
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
! RUN: bbc -emit-hlfir -fcuda %s -o - | fir-opt | FileCheck %s
! Test lowering of CUDA kernel loop directive.