xref: /llvm-project/mlir/test/IR/print-ir-invalid.mlir (revision 7143e3335d92b9f2a987cfccb65461e186af7f4b)
1// # RUN: mlir-opt -test-print-invalid %s | FileCheck %s
2// # RUN: mlir-opt -test-print-invalid %s --mlir-print-assume-verified  | FileCheck %s --check-prefix=ASSUME-VERIFIED
3
4// The pass creates some ops and prints them to stdout, the input is just an
5// empty module.
6module {}
7
8// The operation is invalid because the body does not have a terminator, print
9// the generic form.
10// CHECK:      Invalid operation:
11// CHECK-NEXT: "func.func"() <{function_type = () -> (), sym_name = "test"}> ({
12// CHECK-NEXT: ^bb0:
13// CHECK-NEXT: })
14
15// The operation is valid because the body has a terminator, print the custom
16// form.
17// CHECK:      Valid operation:
18// CHECK-NEXT: func @test() {
19// CHECK-NEXT:   return
20// CHECK-NEXT: }
21
22// With --mlir-print-assume-verified the custom form is printed in both cases.
23// This works in this particular case, but may crash in general.
24
25// ASSUME-VERIFIED:      Invalid operation:
26// ASSUME-VERIFIED-NEXT: func @test() {
27// ASSUME-VERIFIED-NEXT: }
28
29// ASSUME-VERIFIED:      Valid operation:
30// ASSUME-VERIFIED-NEXT: func @test() {
31// ASSUME-VERIFIED-NEXT:   return
32// ASSUME-VERIFIED-NEXT: }
33