[PATCH] D115847: [mlgo][inline] Improve global state tracking

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 22:07:11 PST 2021


mtrofin created this revision.
mtrofin added reviewers: phosek, aeubanks.
Herald added subscribers: ormris, hiraditya, eraman.
mtrofin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The global state refers to the number of the nodes currently in the
module, and the number of direct calls between nodes, accross the
module.

Node counts are not a problem; edge counts are because we want strictly
the kind of edges that affect inlining (direct calls), and that is not
easily obtainable without iteration over the whole module.

This patch avoids relying on analysis invalidation because it turned out
to be too aggressive in some cases. It leverages the fact that Node
objects are stable - they do not get deleted while cgscc passes are
run over the module.

Between the last time we ran the inliner and the next time - i.e.
between consecutive advisor onPassExit / onPassEnter - nodes could be
added, deleted, or updated.

Deletion and updation are easily efficiently tracked by capturing the set
of nodes we exit the InlinerPass (so the one in the LazyCallGraph::SCC at
onPassExit time), and their current edge counts, and then updating at
onPassEnter.

Node addition is more tricky. The current choice is to cross-check if
the set of active nodes known by the LazyCallGraph matches the one we
calculated. If not, then we must have gotten new nodes, and we
re-traverse the module and calculate the edge count.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115847

Files:
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Analysis/LazyCallGraph.h
  llvm/include/llvm/Analysis/MLInlineAdvisor.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Analysis/MLInlineAdvisor.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Transforms/Inline/ML/state-tracking-coro.ll
  llvm/test/Transforms/Inline/ML/state-tracking-scc-splits.ll
  llvm/test/Transforms/Inline/ML/state-tracking.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115847.394742.patch
Type: text/x-patch
Size: 19513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211216/cc258d4c/attachment.bin>


More information about the llvm-commits mailing list