Skip to content

Commit

Permalink
misc: enable --split-input-file --verify-diagnostics (#1011)
Browse files Browse the repository at this point in the history
Currently, `xdsl-opt --split-input-file --verify-diagnostics` will only
diagnose the first chunk and exit, preventing the `invalid.mlir` kind of
filecheck.
This enables it -for verification diagnostics only- and should allow to
clean some filechecks already.
  • Loading branch information
PapyChacal authored May 26, 2023
1 parent 5da2fa8 commit 95702ea
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
16 changes: 0 additions & 16 deletions tests/filecheck/dialects/gpu/all_reduce_body_types.mlir

This file was deleted.

15 changes: 0 additions & 15 deletions tests/filecheck/dialects/gpu/all_reduce_both.mlir

This file was deleted.

32 changes: 32 additions & 0 deletions tests/filecheck/dialects/gpu/invalid.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// RUN: xdsl-opt %s --verify-diagnostics --split-input-file | filecheck %s

"builtin.module"()({
"gpu.module"()({
%init = "arith.constant"() {"value" = 42 : index} : () -> index
%sum = "gpu.all_reduce"(%init) ({
^bb(%lhs : index, %rhs : index):
%sum = "arith.addi"(%lhs, %rhs) : (index, index) -> index
"gpu.yield"(%sum) : (index) -> ()
}) {"op" = #gpu<all_reduce_op add>} : (index) -> index
"gpu.module_end"() : () -> ()
}) {"sym_name" = "all_reduce_both"} : () -> ()
}) {} : () -> ()

// CHECK: gpu.all_reduce can't have both a non-empty region and an op attribute.

// -----

"builtin.module"()({
"gpu.module"()({
%init = "arith.constant"() {"value" = 42 : index} : () -> index
%sum = "gpu.all_reduce"(%init) ({
^bb(%lhs : index):
%c = "arith.constant"() {"value" = 42 : index} : () -> index
%sum = "arith.addi"(%lhs, %c) : (index, index) -> index
"gpu.yield"(%sum) : (index) -> ()
}) : (index) -> index
"gpu.module_end"() : () -> ()
}) {"sym_name" = "all_reduce_body_types"} : () -> ()
}) {} : () -> ()

// CHECK: Expected ['index', 'index'], got ['index']. A gpu.all_reduce's body must have two arguments matching the result type.
5 changes: 2 additions & 3 deletions xdsl/xdsl_opt_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,14 @@ def run(self):
for module in modules:
if not self.args.verify_diagnostics:
self.apply_passes(module)
output_list.append(self.output_resulting_program(module))
else:
try:
self.apply_passes(module)
except DiagnosticException as e:
print(e)
exit(0)
output_list.append(self.output_resulting_program(module))
contents = "// -----\n".join(output_list)

contents = "// -----\n".join(output_list)
self.print_to_output_stream(contents)

def register_all_arguments(self, arg_parser: argparse.ArgumentParser):
Expand Down

0 comments on commit 95702ea

Please sign in to comment.