aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/SROA/phi-and-select.ll
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-11-20 10:02:19 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-11-20 10:02:19 +0000
commit176792990e1b8df4894d0dabddb735abbb254e7c (patch)
tree0f19caa7fd549195f659413541d912438c600d10 /test/Transforms/SROA/phi-and-select.ll
parent310f248c22c5a20eaa4de1e612af3338a89144f3 (diff)
downloadexternal_llvm-176792990e1b8df4894d0dabddb735abbb254e7c.zip
external_llvm-176792990e1b8df4894d0dabddb735abbb254e7c.tar.gz
external_llvm-176792990e1b8df4894d0dabddb735abbb254e7c.tar.bz2
Fix PR14132 and handle OOB loads speculated throuh PHI nodes.
The issue is that we may end up with newly OOB loads when speculating a load into the predecessors of a PHI node, and this confuses the new integer splitting logic in some cases, triggering an assertion failure. In fact, the branch in question must be dead code as it loads from a too-narrow alloca. Add code to handle this gracefully and leave the requisite FIXMEs for both optimizing more aggressively and doing more to aid sanitizing invalid code which triggers these patterns. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SROA/phi-and-select.ll')
-rw-r--r--test/Transforms/SROA/phi-and-select.ll35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/Transforms/SROA/phi-and-select.ll b/test/Transforms/SROA/phi-and-select.ll
index d95e48f..921016a 100644
--- a/test/Transforms/SROA/phi-and-select.ll
+++ b/test/Transforms/SROA/phi-and-select.ll
@@ -390,3 +390,38 @@ if.then:
%tmpcast.d.0 = select i1 undef, i32* %c, i32* %d.0
br label %for.cond
}
+
+define i64 @PR14132(i1 %flag) {
+; CHECK: @PR14132
+; Here we form a PHI-node by promoting the pointer alloca first, and then in
+; order to promote the other two allocas, we speculate the load of the
+; now-phi-node-pointer. In doing so we end up loading a 64-bit value from an i8
+; alloca, which is completely bogus. However, we were asserting on trying to
+; rewrite it. Now it is replaced with undef. Eventually we may replace it with
+; unrechable and even the CFG will go away here.
+entry:
+ %a = alloca i64
+ %b = alloca i8
+ %ptr = alloca i64*
+; CHECK-NOT: alloca
+
+ %ptr.cast = bitcast i64** %ptr to i8**
+ store i64 0, i64* %a
+ store i8 1, i8* %b
+ store i64* %a, i64** %ptr
+ br i1 %flag, label %if.then, label %if.end
+
+if.then:
+ store i8* %b, i8** %ptr.cast
+ br label %if.end
+
+if.end:
+ %tmp = load i64** %ptr
+ %result = load i64* %tmp
+; CHECK-NOT: store
+; CHECK-NOT: load
+; CHECK: %[[result:.*]] = phi i64 [ undef, %if.then ], [ 0, %entry ]
+
+ ret i64 %result
+; CHECK-NEXT: ret i64 %[[result]]
+}