File: test-symbol-uses.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 (70 lines) | stat: -rw-r--r-- 2,448 bytes parent folder | download | duplicates (12)
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
66
67
68
69
70
// RUN: mlir-opt -allow-unregistered-dialect %s -test-symbol-uses -split-input-file -verify-diagnostics

// Symbol references to the module itself don't affect uses of symbols within
// its table.
// expected-remark@below {{symbol_removable function successfully erased}}
module attributes {sym.outside_use = @symbol_foo } {
  // expected-remark@+1 {{symbol has 3 uses}}
  func.func private @symbol_foo()

  // expected-remark@below {{symbol has no uses}}
  // expected-remark@below {{found use of symbol : @symbol_foo}}
  // expected-remark@below {{symbol contains 3 nested references}}
  func.func @symbol_bar() attributes {sym.use = @symbol_foo} {
    // expected-remark@+1 {{found use of symbol : @symbol_foo}}
    "foo.op"() {
      non_symbol_attr,
      use = [{nested_symbol = [@symbol_foo]}],
      z_other_non_symbol_attr
    } : () -> ()
    // expected-remark@+1 {{found use of symbol : @symbol_foo}}
    "foo.op"() { use = distinct[0]<@symbol_foo> } : () -> ()
  }

  // expected-remark@below {{symbol has no uses}}
  func.func private @symbol_removable()

  // expected-remark@+1 {{symbol has 1 use}}
  func.func private @symbol_baz()

  // expected-remark@+1 {{found use of symbol : @symbol_baz}}
  module attributes {test.reference = @symbol_baz} {
    "foo.op"() {test.nested_reference = @symbol_baz} : () -> ()
  }
}

// -----

// Test nested attribute support
module {
  // expected-remark@+1 {{symbol has 2 uses}}
  module @module_b {
    // expected-remark@+1 {{symbol has 1 uses}}
    module @module_c {
      // expected-remark@+1 {{symbol has 1 uses}}
      func.func nested @foo()
    }
  }

  // expected-remark@below {{symbol has no uses}}
  // expected-remark@below {{symbol contains 2 nested references}}
  func.func @symbol_bar() {
    // expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "foo"}}
    // expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "module_c"}}
    // expected-remark@below {{found use of symbol : @module_b::@module_c::@foo : "module_b"}}
    // expected-remark@below {{found use of symbol : @module_b : "module_b"}}
    "foo.op"() {
      use_1 = [{ nested_symbol = [@module_b::@module_c::@foo]}],
      use_2 = @module_b
    } : () -> ()
  }
}


// -----

// expected-remark@+1 {{contains an unknown nested operation that 'may' define a new symbol table}}
func.func @symbol_bar() {
  "foo.possibly_unknown_symbol_table"() ({
  }) : () -> ()
}