diff options
Diffstat (limited to 'lib/Target/JSBackend/SimplifyAllocas.cpp')
-rw-r--r-- | lib/Target/JSBackend/SimplifyAllocas.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Target/JSBackend/SimplifyAllocas.cpp b/lib/Target/JSBackend/SimplifyAllocas.cpp index 2fda6be948..858ded32a1 100644 --- a/lib/Target/JSBackend/SimplifyAllocas.cpp +++ b/lib/Target/JSBackend/SimplifyAllocas.cpp @@ -72,12 +72,11 @@ bool SimplifyAllocas::runOnFunction(Function &Func) { } std::vector<Instruction*> Aliases; // the bitcasts of this alloca for (Instruction::use_iterator UI = AI->use_begin(), UE = AI->use_end(); UI != UE && !Fail; ++UI) { - Instruction *U = dyn_cast<Instruction>(*UI); - if (!U || U->getOpcode() != Instruction::BitCast) { Fail = true; break; } + Instruction *U = cast<Instruction>(*UI); + if (U->getOpcode() != Instruction::BitCast) { Fail = true; break; } // bitcasting just to do loads and stores is ok for (Instruction::use_iterator BUI = U->use_begin(), BUE = U->use_end(); BUI != BUE && !Fail; ++BUI) { - Instruction *BU = dyn_cast<Instruction>(*BUI); - if (!BU) { Fail = true; break; } + Instruction *BU = cast<Instruction>(*BUI); if (BU->getOpcode() == Instruction::Load) { CHECK_TYPE(BU->getType()); break; @@ -88,7 +87,7 @@ bool SimplifyAllocas::runOnFunction(Function &Func) { } if (!Fail) Aliases.push_back(U); } - if (!Fail && Aliases.size() > 0) { + if (!Fail && Aliases.size() > 0 && ActualType) { // success, replace the alloca and the bitcast aliases with a single simple alloca AllocaInst *NA = new AllocaInst(ActualType, ConstantInt::get(i32, 1), "", I); NA->takeName(AI); |