]> granicus.if.org Git - llvm/commit
Create PHI node for the return value only when the return value has uses.
authorTaewook Oh <twoh@fb.com>
Mon, 28 Aug 2017 18:57:00 +0000 (18:57 +0000)
committerTaewook Oh <twoh@fb.com>
Mon, 28 Aug 2017 18:57:00 +0000 (18:57 +0000)
commit2dc192844129cf91bf206a9a9dc20085fcd1a35b
tree6a58a613392ddb4a890b136813f3977501d29776
parentfc50e1c6121255333bc42d6faf2b524c074eae25
Create PHI node for the return value only when the return value has uses.

Summary:
Currently, a phi node is created in the normal destination to unify the return values from promoted calls and the original indirect call. This patch makes this phi node to be created only when the return value has uses.

This patch is necessary to generate valid code, as compiler crashes with the attached test case without this patch. Without this patch, an illegal phi node that has no incoming value from `entry`/`catch` is created in `cleanup` block.

I think existing implementation is good as far as there is at least one use of the original indirect call. `insertCallRetPHI` creates a new phi node in the normal destination block only when the original indirect call dominates its use and the normal destination block. Otherwise, `fixupPHINodeForNormalDest` will handle the unification of return values naturally without creating a new phi node. However, if there's no use, `insertCallRetPHI` still creates a new phi node even when the original indirect call does not dominate the normal destination block, because `getCallRetPHINode` returns false.

Reviewers: xur, davidxl, danielcdh

Reviewed By: xur

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311906 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
test/Transforms/PGOProfile/icp_covariant_call_return.ll
test/Transforms/PGOProfile/icp_invoke_nouse.ll [new file with mode: 0644]