[all-commits] [llvm/llvm-project] 9b92e4: [mlir] Add support for attaching a visibility to s...

River Riddle via All-commits all-commits at lists.llvm.org
Mon Jan 13 16:12:50 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9b92e4fbdb5bc4fdd21702e0ce104dfcac6a54a7
      https://github.com/llvm/llvm-project/commit/9b92e4fbdb5bc4fdd21702e0ce104dfcac6a54a7
  Author: River Riddle <riverriddle at google.com>
  Date:   2020-01-13 (Mon, 13 Jan 2020)

  Changed paths:
    M mlir/include/mlir/IR/SymbolTable.h
    M mlir/lib/IR/Module.cpp
    M mlir/lib/IR/SymbolTable.cpp
    M mlir/test/IR/traits.mlir
    M mlir/test/lib/TestDialect/TestOps.td

  Log Message:
  -----------
  [mlir] Add support for attaching a visibility to symbols.

Summary:
The visibility defines the structural reachability of the symbol within the IR. Symbols can define one of three visibilities:

* Public
The symbol \may be accessed from outside of the visible IR. We cannot assume that we can observe all of the uses of this symbol.

* Private
The symbol may only be referenced from within the operations in the current symbol table, via SymbolRefAttr.

* Nested
The symbol may be referenced by operations in symbol tables above the current symbol table, as long as each symbol table parent also defines a non-private symbol. This allows or referencing the symbol from outside of the defining symbol table, while retaining the ability for the compiler to see all uses.

These properties help to reason about the properties of a symbol, and will be used in a follow up to implement a dce pass on dead symbols.

A few examples of what this would look like in the IR are shown below:

  module @public_module {
    // This function can be accessed by 'live.user'
    func @nested_function() attributes { sym_visibility = "nested" }

    // This function cannot be accessed outside of 'public_module'
   func @private_function() attributes { sym_visibility = "private" }
  }

  // This function can only be accessed from within this module.
  func @private_function() attributes { sym_visibility = "private" }

  // This function may be referenced externally.
  func @public_function()

  "live.user"() {uses = [@public_module::@nested_function,
                                      @private_function,
                                      @public_function]} : () -> ()

Depends On D72043

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D72044




More information about the All-commits mailing list