• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: mlir-opt -allow-unregistered-dialect %s -test-inline | FileCheck %s
2
3// CHECK-LABEL: func @inline_with_arg
4func @inline_with_arg(%arg0 : i32) -> i32 {
5  // CHECK-NEXT: %[[ADD:.*]] = addi %{{.*}}, %{{.*}} : i32
6  // CHECK-NEXT: return %[[ADD]] : i32
7  %fn = "test.functional_region_op"() ({
8  ^bb0(%a : i32):
9    %b = addi %a, %a : i32
10    "test.return"(%b) : (i32) -> ()
11  }) : () -> ((i32) -> i32)
12
13  %0 = call_indirect %fn(%arg0) : (i32) -> i32
14  return %0 : i32
15}
16
17// CHECK-LABEL: func @no_inline_invalid_nested_operation
18func @no_inline_invalid_nested_operation() {
19  // CHECK: call_indirect
20
21  // test.region is analyzed recursively, so it must not have an invalid op.
22
23  %fn = "test.functional_region_op"() ({
24    "test.region"() ({
25      "foo.noinline_operation"() : () -> ()
26    }) : () -> ()
27    "test.return"() : () -> ()
28  }) : () -> (() -> ())
29
30  call_indirect %fn() : () -> ()
31  return
32}
33
34// CHECK-LABEL: func @inline_ignore_invalid_nested_operation
35func @inline_ignore_invalid_nested_operation() {
36  // CHECK-NOT: call_indirect
37
38  // test.functional_region_op is not analyzed recursively, so it may have an
39  // invalid op.
40
41  %fn = "test.functional_region_op"() ({
42    %internal_fn = "test.functional_region_op"() ({
43      "foo.noinline_operation"() : () -> ()
44    }) : () -> (() -> ())
45    "test.return"() : () -> ()
46  }) : () -> (() -> ())
47
48  call_indirect %fn() : () -> ()
49  return
50}
51
52// CHECK-LABEL: func @no_inline_invalid_dest_region
53func @no_inline_invalid_dest_region() {
54  // CHECK: call_indirect
55
56  // foo.unknown_region is unknown, so we can't inline into it.
57
58  "foo.unknown_region"() ({
59    %fn = "test.functional_region_op"() ({
60      "test.return"() : () -> ()
61    }) : () -> (() -> ())
62    call_indirect %fn() : () -> ()
63    "test.return"() : () -> ()
64  }) : () -> ()
65
66  return
67}
68