File: print-value-users.mlir

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (65 lines) | stat: -rw-r--r-- 2,969 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RUN: mlir-opt -allow-unregistered-dialect -mlir-print-value-users -split-input-file %s | FileCheck %s

module {
    // CHECK: %[[ARG0:.+]]: i32, %[[ARG1:.+]]: i32, %[[ARG2:.+]]: i32
    func.func @foo(%arg0: i32, %arg1: i32, %arg3: i32) -> i32 {
        // CHECK-NEXT: // %[[ARG0]] is used by %[[ARG0U1:.+]], %[[ARG0U2:.+]], %[[ARG0U3:.+]]
        // CHECK-NEXT: // %[[ARG1]] is used by %[[ARG1U1:.+]], %[[ARG1U2:.+]]
        // CHECK-NEXT: // %[[ARG2]] is unused
        // CHECK-NEXT: test.noop
        // CHECK-NOT: // unused
        "test.noop"() : () -> ()
        // When no result is produced, an id should be printed.
        // CHECK-NEXT: // id: %[[ARG0U3]]
        "test.no_result"(%arg0) {} : (i32) -> ()
        // Check for unused result.
        // CHECK-NEXT: %[[ARG0U2]] =
        // CHECK-SAME: // unused
        %1 = "test.unused_result"(%arg0, %arg1) {} : (i32, i32) -> i32
        // Check that both users are printed.
        // CHECK-NEXT: %[[ARG0U1]] =
        // CHECK-SAME: // users: %[[A:.+]]#0, %[[A]]#1
        %2 = "test.one_result"(%arg0, %arg1) {} : (i32, i32) -> i32
        // For multiple results, users should be grouped per result.
        // CHECK-NEXT: %[[A]]:2 =
        // CHECK-SAME: // users: (%[[B:.+]], %[[C:.+]]), (%[[B]], %[[D:.+]])
        %3:2 = "test.many_results"(%2) {} : (i32) -> (i32, i32)
        // Two results are produced, but there is only one user.
        // CHECK-NEXT: // users:
        %7:2 = "test.many_results"() : () -> (i32, i32)
        // CHECK-NEXT: %[[C]] =
        // Result is used twice in next operation but it produces only one result.
        // CHECK-SAME: // user:
        %4 = "test.foo"(%3#0) {} : (i32) -> i32
        // CHECK-NEXT: %[[D]] =
        %5 = "test.foo"(%3#1, %4, %4) {} : (i32, i32, i32) -> i32
        // CHECK-NEXT: %[[B]] =
        // Result is not used in any other result but in two operations.
        // CHECK-SAME: // users:
        %6 = "test.foo"(%3#0, %3#1) {} : (i32, i32) -> i32
        "test.no_result"(%6) {} : (i32) -> ()
        "test.no_result"(%7#0) : (i32) -> ()
        return %6: i32
    }
}

// -----

module {
    // Check with nested operation.
    // CHECK: %[[CONSTNAME:.+]] = arith.constant
    %0 = arith.constant 42 : i32
    %test = "test.outerop"(%0) ({
        // CHECK: "test.innerop"(%[[CONSTNAME]]) : (i32) -> () // id: %
        "test.innerop"(%0) : (i32) -> ()
    // CHECK: (i32) -> i32 // users: %r, %s, %p, %p_0, %q
    }): (i32) -> i32

    // Check named results.
    // CHECK-NEXT: // users: (%u, %v), (unused), (%u, %v, %r, %s)
    %p:2, %q = "test.custom_result_name"(%test) {names = ["p", "p", "q"]} : (i32) -> (i32, i32, i32)
    // CHECK-NEXT: // users: (unused), (%u, %v)
    %r, %s = "test.custom_result_name"(%q#0, %q#0, %test) {names = ["r", "s"]} : (i32, i32, i32) -> (i32, i32)
    // CHECK-NEXT: // unused
    %u, %v = "test.custom_result_name"(%s, %q#0, %p) {names = ["u", "v"]} : (i32, i32, i32) -> (i32, i32)
}