[ICP] Expose unconditional call promotion interface
authorMatthew Simpson <mssimpso@codeaurora.org>
Wed, 20 Dec 2017 19:26:37 +0000 (19:26 +0000)
committerMatthew Simpson <mssimpso@codeaurora.org>
Wed, 20 Dec 2017 19:26:37 +0000 (19:26 +0000)
commitcb35c5d5c2074ceef6c70f668245af7b46ca7504
tree96d998c389540a230ecb84dc4fd14842fee46baf
parent07820f2fe4482a58031f4101d12b3abb092fc4e2
[ICP] Expose unconditional call promotion interface

This patch modifies the indirect call promotion utilities by exposing and using
an unconditional call promotion interface. 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.

Differential Revision: https://reviews.llvm.org/D40751

llvm-svn: 321210
llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h
llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll
llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
llvm/test/Transforms/PGOProfile/icp_invoke.ll
llvm/test/Transforms/PGOProfile/icp_invoke_nouse.ll
llvm/test/Transforms/PGOProfile/icp_vararg.ll
llvm/test/Transforms/PGOProfile/indirect_call_promotion.ll