This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add support for attaching a visibility to symbols.
ClosedPublic

Authored by rriddle on Dec 31 2019, 3:46 PM.

Details

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

Diff Detail

Event Timeline

rriddle created this revision.Dec 31 2019, 3:46 PM
rriddle updated this revision to Diff 235739.Dec 31 2019, 4:08 PM

Fix typo.

Unit tests: pass. 61162 tests passed, 0 failed and 728 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Unit tests: pass. 61162 tests passed, 0 failed and 728 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Unit tests: pass. 61735 tests passed, 0 failed and 779 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

mehdi_amini accepted this revision.Jan 12 2020, 3:27 PM
mehdi_amini added inline comments.
mlir/lib/IR/Module.cpp
85

Can you update the comment?

This revision is now accepted and ready to land.Jan 12 2020, 3:27 PM
rriddle updated this revision to Diff 237793.Jan 13 2020, 3:19 PM

Address comments.

rriddle marked an inline comment as done.Jan 13 2020, 3:20 PM

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

This revision was automatically updated to reflect the committed changes.