[PATCH] D94644: [Inliner] Inline alwaysinline calls first

Arthur Eubanks via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 13 18:58:19 PST 2021


aeubanks created this revision.
Herald added subscribers: wenlei, steven_wu, hiraditya, eraman.
aeubanks requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

And revert much of D91567 <https://reviews.llvm.org/D91567>.
D91567 <https://reviews.llvm.org/D91567> ended up putting the mandatory inlining pass in a different CGSCC
pipeline than the function simplification pipeline, causing alwaysinline
functions to not be optimized when inlined into another function,
causing PR48734. Much of the design of D91567 <https://reviews.llvm.org/D91567> was to potentially support
future work to run the function simplification pipeline twice, once
before inlining. However, that hasn't happened yet and can be revisited
in the future.

This sorts the initial list of CallBases so that we handle alwaysinline
calls first. Since we want to process as many calls in one functions at
a time, we have to use a stable sort.

This actually doesn't handle all alwaysinline cases properly. For
example, within an SCC, if an alwaysinline function contains another
alwaysinline call and is inlined, the newly inlined alwaysinline call
will be processed after other calls since it was not in the initial list
of CallBases.  Then we can end up with another case of PR46945 where an
alwaysinline function can't be inlined because a mutually recursive
function was inlined first.  However, it seems rare enough to not bother
with this case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94644

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/optimization-remark-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-module-inliner-wrapper.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/Inline/inline_stats.ll
  llvm/test/Transforms/Inline/pr46945.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94644.316548.patch
Type: text/x-patch
Size: 31740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210114/3f0ce203/attachment-0001.bin>


More information about the cfe-commits mailing list