[PATCH] D47816: [InstCombine] Don't sink instructions across inlined function call.

Renlin Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 6 03:18:42 PDT 2018


renlin created this revision.
Herald added subscribers: llvm-commits, eraman.

instcombine pass will try to sink an instruction to the place where the value
is used when the CFG is very simple. However, this doesn't take the inlined
function call into account.

      

When a function call is inlined, it will complicate the CFG, which makes the
code transformation not beneficial. The sinking will increase the live range of variables.

In the addeded test case, inline_func is marked with alwaysinline
attribute. Inside inline_func, there is a loop.

      

If the function is inlined before instcombine, the sinking won't happen,
because the CFG between the value and user is complexer than expected.
On the other hand, if instcombine pass is run before alwaysinline pass,
the the load instruction will be sinked to the only user, together will other
variables used by it only.

      

Here in the patch, function with either inlinehint or alwayinline
attributes will be skipped. It might be too strict, comments and
suggestions are welcome.


Repository:
  rL LLVM

https://reviews.llvm.org/D47816

Files:
  lib/Transforms/InstCombine/InstructionCombining.cpp
  test/Transforms/InstCombine/sink_inline.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47816.150100.patch
Type: text/x-patch
Size: 6529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180606/4a5c368f/attachment.bin>


More information about the llvm-commits mailing list