[PATCH] D40751: [ICP] Expose unconditional call promotion interface

Matthew Simpson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 13:25:14 PST 2017


mssimpso created this revision.

This patch modifies the common indirect call promotion utilities by by exposing and using an unconditional call promotion interface. These changes are meant to accommodate the planned use case in https://reviews.llvm.org/D39869. The unconditional promotion interface (i.e., call promotion without creating an if-then-else) can be used if it's known that an indirect call has only one possible callee. The existing conditional promotion interface uses this unconditional interface to promote an indirect call after it has been versioned and placed within the "then" block.

A consequence of unconditional promotion is that the fix-up operations for phi nodes in the normal destination of invoke instructions are changed. This is necessary because the existing implementation assumed that an invoke had been versioned, creating a "merge" block where a return value bitcast could be placed. In the new implementation, the edge between a promoted invoke's parent block and its normal destination is split if needed to add a bitcast for the return value. If the invoke is also versioned, the phi node merging the return value of the promoted and original invoke instructions is placed in the "merge" block.

This patch also changes the interface for conditional call site promotion so that the given call site is modified, and a new indirect call site is created and returned (the call site in the "else" block). Previously, a new direct call site was created and returned (the call site in the "then" block), and the given call site remained unmodified. This matches the interface for unconditional promotion in that the given call site is modified in place. There are also some superficial changes to the existing test cases. For example, some values have different names, and bitcast instructions are avoided when unnecessary.


https://reviews.llvm.org/D40751

Files:
  include/llvm/Transforms/Utils/CallPromotionUtils.h
  lib/Transforms/IPO/SampleProfile.cpp
  lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
  lib/Transforms/Utils/CallPromotionUtils.cpp
  test/Transforms/PGOProfile/icp_covariant_call_return.ll
  test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
  test/Transforms/PGOProfile/icp_invoke.ll
  test/Transforms/PGOProfile/icp_invoke_nouse.ll
  test/Transforms/PGOProfile/icp_vararg.ll
  test/Transforms/PGOProfile/indirect_call_promotion.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40751.125210.patch
Type: text/x-patch
Size: 24090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171201/9b908415/attachment.bin>


More information about the llvm-commits mailing list