Skip to content

[mlir][async] Avoid crash when not using func.func #72801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/Async/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def AsyncParallelFor : Pass<"async-parallel-for", "ModuleOp"> {
let dependentDialects = [
"arith::ArithDialect",
"async::AsyncDialect",
"func::FuncDialect",
"scf::SCFDialect"
];
}
Expand Down
19 changes: 19 additions & 0 deletions mlir/test/Dialect/Async/async-parallel-for-compute-fn.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ func.func @sink_constant_step(%arg0: memref<?xf32>, %lb: index, %ub: index) {

// -----

// Smoke test that parallel for doesn't crash when func dialect is not used.

// CHECK-LABEL: llvm.func @without_func_dialect()
llvm.func @without_func_dialect() {
%cst = arith.constant 0.0 : f32

%c0 = arith.constant 0 : index
%c22 = arith.constant 22 : index
%c1 = arith.constant 1 : index
%54 = memref.alloc() : memref<22xf32>
%alloc_4 = memref.alloc() : memref<22xf32>
scf.parallel (%arg0) = (%c0) to (%c22) step (%c1) {
memref.store %cst, %alloc_4[%arg0] : memref<22xf32>
}
llvm.return
}

// -----

// Check that for statically known inner loop bound block size is aligned and
// inner loop uses statically known loop trip counts.

Expand Down
2 changes: 2 additions & 0 deletions mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,8 @@ void OpEmitter::genAttrNameGetters() {
const char *const getAttrName = R"(
assert(index < {0} && "invalid attribute index");
assert(name.getStringRef() == getOperationName() && "invalid operation name");
assert(name.isRegistered() && "Operation isn't registered, missing a "
"dependent dialect loading?");
return name.getAttributeNames()[index];
)";
method->body() << formatv(getAttrName, attributes.size());
Expand Down