diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 4fe5ddf3335..090d3ef53e3 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -836,8 +836,7 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, // blocks are available as virtual registers. for (BasicBlock::iterator I = LLVMBB->begin(), E = LLVMBB->end(); I != E;++I) if (!I->use_empty()) { - std::map::iterator VMI = - FuncInfo.ValueMap.find(I); + std::map::iterator VMI =FuncInfo.ValueMap.find(I); if (VMI != FuncInfo.ValueMap.end()) CopyValueToVirtualRegister(SDL, I, VMI->second); } @@ -878,7 +877,13 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, Reg = RegOut; } else { Reg = FuncInfo.ValueMap[PHIOp]; - assert(Reg && "Didn't codegen value into a register!??"); + if (Reg == 0) { + assert(isa(PHIOp) && + FuncInfo.StaticAllocaMap.count(cast(PHIOp)) && + "Didn't codegen value into a register!??"); + Reg = FuncInfo.CreateRegForValue(PHIOp); + CopyValueToVirtualRegister(SDL, PHIOp, Reg); + } } // Remember that this register needs to added to the machine PHI node as