diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2015-09-23 15:41:09 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2015-09-23 15:41:09 +0000 |
| commit | fa36bde2f66825e27aac7d753efc11e7549a9f84 (patch) | |
| tree | a169cf6809cfb949978ba93e37166a0626f8c58d /llvm/test/Transforms | |
| parent | 2a6c13274c5cc36654073f3865f7bdf5bf10250d (diff) | |
| download | bcm5719-llvm-fa36bde2f66825e27aac7d753efc11e7549a9f84.tar.gz bcm5719-llvm-fa36bde2f66825e27aac7d753efc11e7549a9f84.zip | |
[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.
llvm-svn: 248387
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/DeadArgElim/aggregates.ll | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/llvm/test/Transforms/DeadArgElim/aggregates.ll b/llvm/test/Transforms/DeadArgElim/aggregates.ll index 68d25342558..2eca76a4a4e 100644 --- a/llvm/test/Transforms/DeadArgElim/aggregates.ll +++ b/llvm/test/Transforms/DeadArgElim/aggregates.ll @@ -159,4 +159,28 @@ define internal i8 @outer() { %val = load i8, i8* %resptr ret i8 %val -}
\ No newline at end of file +} + +define internal { i32 } @agg_ret() { +entry: + unreachable +} + +; CHECK-LABEL: define void @PR24906 +; CHECK: %[[invoke:.*]] = invoke i32 @agg_ret() +; CHECK: %[[oldret:.*]] = insertvalue { i32 } undef, i32 %[[invoke]], 0 +; CHECK: phi { i32 } [ %[[oldret]], +define void @PR24906() personality i32 (i32)* undef { +entry: + %tmp2 = invoke { i32 } @agg_ret() + to label %bb3 unwind label %bb4 + +bb3: + %tmp3 = phi { i32 } [ %tmp2, %entry ] + unreachable + +bb4: + %tmp4 = landingpad { i8*, i32 } + cleanup + unreachable +} |

