diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-24 03:29:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-24 03:29:07 +0000 |
commit | 867be59684afef29f058385c6618ec7753596ffc (patch) | |
tree | 29a93767849421b6f79d66573b94614a3862cac6 | |
parent | 51e62f0f73b2d2a32c2a5b98402114e4c71dc14f (diff) |
fix PR9017, a bug where we'd assert when promoting in unreachable
code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124100 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/SSAUpdater.cpp | 3 | ||||
-rw-r--r-- | test/Transforms/ScalarRepl/crash.ll | 20 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/SSAUpdater.cpp b/lib/Transforms/Utils/SSAUpdater.cpp index 0474a7842d..3896d9851b 100644 --- a/lib/Transforms/Utils/SSAUpdater.cpp +++ b/lib/Transforms/Utils/SSAUpdater.cpp @@ -469,6 +469,9 @@ run(const SmallVectorImpl<Instruction*> &Insts) const { LoadInst *ALoad = LiveInLoads[i]; Value *NewVal = SSA.GetValueInMiddleOfBlock(ALoad->getParent()); replaceLoadWithValue(ALoad, NewVal); + + // Avoid assertions in unreachable code. + if (NewVal == ALoad) NewVal = UndefValue::get(NewVal->getType()); ALoad->replaceAllUsesWith(NewVal); ReplacedLoads[ALoad] = NewVal; } diff --git a/test/Transforms/ScalarRepl/crash.ll b/test/Transforms/ScalarRepl/crash.ll new file mode 100644 index 0000000000..7198e671fa --- /dev/null +++ b/test/Transforms/ScalarRepl/crash.ll @@ -0,0 +1,20 @@ +; RUN: opt -scalarrepl %s -disable-output +; RUN: opt -scalarrepl-ssa %s -disable-output + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0.0" + +; PR9017 +define void @test1() nounwind readnone ssp { +entry: + %l_72 = alloca i32*, align 8 + unreachable + +for.cond: ; preds = %for.cond + %tmp1.i = load i32** %l_72, align 8 + store i32* %tmp1.i, i32** %l_72, align 8 + br label %for.cond + +if.end: ; No predecessors! + ret void +} |