[PATCH] D72044: [mlir] Add support for attaching a visibility to symbols.

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 31 15:54:03 PST 2019


rriddle created this revision.
rriddle added a reviewer: jpienaar.
Herald added subscribers: llvm-commits, nicolasvasilache, antiagainst, shauheen, burmako, mehdi_amini.
Herald added a project: LLVM.

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 <https://reviews.llvm.org/D72043>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72044

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72044.235738.patch
Type: text/x-patch
Size: 8466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191231/13cce955/attachment.bin>


More information about the llvm-commits mailing list