summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2015-02-11 23:13:11 +0000
committerTim Northover <tnorthover@apple.com>2015-02-11 23:13:11 +0000
commit02438033e864f368cfc6ff3c915b2d113b46dde9 (patch)
tree9965e02e26cad4e8ac1d3f0ee17254cb8a17f738 /llvm/test/Transforms
parentef6baea74e4690911943637a4f660579391414b1 (diff)
downloadbcm5719-llvm-02438033e864f368cfc6ff3c915b2d113b46dde9.tar.gz
bcm5719-llvm-02438033e864f368cfc6ff3c915b2d113b46dde9.zip
DeadArgElim: aggregate Return assessment properly.
I mistakenly thought the liveness of each "RetVal(F, i)" depended only on F. It actually depends on the index too, which means we need to be careful about how the results are combined before return. In particular if a single Use returns Live, that counts for the entire object, at the granularity we're considering. llvm-svn: 228885
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/DeadArgElim/aggregates.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/DeadArgElim/aggregates.ll b/llvm/test/Transforms/DeadArgElim/aggregates.ll
index 84370834e11..f54c6c9ea44 100644
--- a/llvm/test/Transforms/DeadArgElim/aggregates.ll
+++ b/llvm/test/Transforms/DeadArgElim/aggregates.ll
@@ -130,3 +130,33 @@ define i32 @test_ret_applies_to_all() {
%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* %resptr
+ ret i8 %val
+} \ No newline at end of file
OpenPOWER on IntegriCloud