X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=test%2FTransforms%2FDeadArgElim%2Faggregates.ll;h=2eca76a4a4e30ae99d228c1b9225f1c2155bb8fa;hp=153289947c182fc6171595c43bfe5afdf4ac3a1a;hb=6b423577e24caf97187ea16acbca64228cbe32ee;hpb=968ed6a5f0e69e75de0b61982e19698848442c6f diff --git a/test/Transforms/DeadArgElim/aggregates.ll b/test/Transforms/DeadArgElim/aggregates.ll index 153289947c1..2eca76a4a4e 100644 --- a/test/Transforms/DeadArgElim/aggregates.ll +++ b/test/Transforms/DeadArgElim/aggregates.ll @@ -113,3 +113,74 @@ define void @test_can_shrink_arrays() { ret void } + +; Case 5: %in gets passed directly to the return. It should mark be marked as +; used if *any* of the return values are, not just if value 0 is. + +; CHECK-LABEL: define internal i32 @ret_applies_to_all({ i32, i32 } %in) +; CHECK: [[RET:%.*]] = extractvalue { i32, i32 } %in, 1 +; CHECK: ret i32 [[RET]] + +define internal {i32, i32} @ret_applies_to_all({i32, i32} %in) { + ret {i32, i32} %in +} + +define i32 @test_ret_applies_to_all() { + %val = call {i32, i32} @ret_applies_to_all({i32, i32} {i32 42, i32 43}) + %ret = extractvalue {i32, i32} %val, 1 + ret i32 %ret +} + +; Case 6: When considering @mid, the return instruciton has sub-value 0 +; unconditionally live, but 1 only conditionally live. Since at that level we're +; applying the results to the whole of %res, this means %res is live and cannot +; be reduced. There is scope for further optimisation here (though not visible +; in this test-case). + +; CHECK-LABEL: define internal { i8*, i32 } @inner() + +define internal {i8*, i32} @mid() { + %res = call {i8*, i32} @inner() + %intval = extractvalue {i8*, i32} %res, 1 + %tst = icmp eq i32 %intval, 42 + br i1 %tst, label %true, label %true + +true: + ret {i8*, i32} %res +} + +define internal {i8*, i32} @inner() { + ret {i8*, i32} {i8* null, i32 42} +} + +define internal i8 @outer() { + %res = call {i8*, i32} @mid() + %resptr = extractvalue {i8*, i32} %res, 0 + + %val = load i8, i8* %resptr + ret i8 %val +} + +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 +}