[DeadArgElim] Split the invoke successor edge
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 23 Sep 2015 15:41:09 +0000 (15:41 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 23 Sep 2015 15:41:09 +0000 (15:41 +0000)
commit6b423577e24caf97187ea16acbca64228cbe32ee
tree70f94e3ab36ba25d8c6e15fb577c263cbcccbb67
parentc173ab2ec2f9f99f5c8abf934b13a71e72c6806b
[DeadArgElim] Split the invoke successor edge

Invoking a function which returns an aggregate can sometimes be
transformed to return a scalar value.  However, this means that we need
to create an insertvalue instruction(s) to recreate the correct
aggregate type.  We achieved this by inserting an insertvalue
instruction at the invoke's normal successor.  However, this is not
feasible if the normal successor uses the invoke's return value inside a
PHI node.

Instead, split the edge between the invoke and the unwind successor and
create the insertvalue instruction in the new basic block.  The new
basic block's successor will be the old invoke successor which leaves
us with IR which is well behaved.

This fixes PR24906.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248387 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/DeadArgumentElimination.cpp
test/Transforms/DeadArgElim/aggregates.ll