From b4017769aed86df862acfcc50c9fa4623df8c1e2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 24 Jan 2011 03:29:07 +0000 Subject: fix PR9017, a bug where we'd assert when promoting in unreachable code. llvm-svn: 124100 --- llvm/lib/Transforms/Utils/SSAUpdater.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp index 0474a7842d1..3896d9851b2 100644 --- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp +++ b/llvm/lib/Transforms/Utils/SSAUpdater.cpp @@ -469,6 +469,9 @@ run(const SmallVectorImpl &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; } -- cgit v1.2.3