diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-07 21:34:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-07 21:34:19 +0000 |
commit | f44fd88e9cdd7b47acb71ac78e3dccb91319c72d (patch) | |
tree | 85a450f28c71154fdf939a00af5e754676061997 /lib | |
parent | ebda942efcb86634a6581aae76a0d0c92c4a232e (diff) | |
download | external_llvm-f44fd88e9cdd7b47acb71ac78e3dccb91319c72d.zip external_llvm-f44fd88e9cdd7b47acb71ac78e3dccb91319c72d.tar.gz external_llvm-f44fd88e9cdd7b47acb71ac78e3dccb91319c72d.tar.bz2 |
Fix handling of dead PHI nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index e6a8067..4ba16f6 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -141,13 +141,15 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli, // appropriate. PHINode *PN; for (BasicBlock::iterator I = BB->begin(); - (PN = dyn_cast<PHINode>(I)); ++I) { - unsigned NumElements =TLI.getNumElements(TLI.getValueType(PN->getType())); - unsigned PHIReg = ValueMap[PN]; - assert(PHIReg && "PHI node does not have an assigned virtual register!"); - for (unsigned i = 0; i != NumElements; ++i) - BuildMI(MBB, TargetInstrInfo::PHI, PN->getNumOperands(), PHIReg+i); - } + (PN = dyn_cast<PHINode>(I)); ++I) + if (!PN->use_empty()) { + unsigned NumElements = + TLI.getNumElements(TLI.getValueType(PN->getType())); + unsigned PHIReg = ValueMap[PN]; + assert(PHIReg &&"PHI node does not have an assigned virtual register!"); + for (unsigned i = 0; i != NumElements; ++i) + BuildMI(MBB, TargetInstrInfo::PHI, PN->getNumOperands(), PHIReg+i); + } } } @@ -786,27 +788,29 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, // nodes and Machine PHI nodes, but the incoming operands have not been // emitted yet. for (BasicBlock::iterator I = SuccBB->begin(); - (PN = dyn_cast<PHINode>(I)); ++I) { - unsigned Reg; - Value *PHIOp = PN->getIncomingValueForBlock(LLVMBB); - if (Constant *C = dyn_cast<Constant>(PHIOp)) { - unsigned &RegOut = ConstantsOut[C]; - if (RegOut == 0) { - RegOut = FuncInfo.CreateRegForValue(C); - CopyValueToVirtualRegister(SDL, C, RegOut); + (PN = dyn_cast<PHINode>(I)); ++I) + if (!PN->use_empty()) { + unsigned Reg; + Value *PHIOp = PN->getIncomingValueForBlock(LLVMBB); + if (Constant *C = dyn_cast<Constant>(PHIOp)) { + unsigned &RegOut = ConstantsOut[C]; + if (RegOut == 0) { + RegOut = FuncInfo.CreateRegForValue(C); + CopyValueToVirtualRegister(SDL, C, RegOut); + } + Reg = RegOut; + } else { + Reg = FuncInfo.ValueMap[PHIOp]; + assert(Reg && "Didn't codegen value into a register!??"); } - Reg = RegOut; - } else { - Reg = FuncInfo.ValueMap[PHIOp]; - assert(Reg && "Didn't codegen value into a register!??"); + + // Remember that this register needs to added to the machine PHI node as + // the input for this MBB. + unsigned NumElements = + TLI.getNumElements(TLI.getValueType(PN->getType())); + for (unsigned i = 0, e = NumElements; i != e; ++i) + PHINodesToUpdate.push_back(std::make_pair(MBBI++, Reg+i)); } - - // Remember that this register needs to added to the machine PHI node as - // the input for this MBB. - unsigned NumElements =TLI.getNumElements(TLI.getValueType(PN->getType())); - for (unsigned i = 0, e = NumElements; i != e; ++i) - PHINodesToUpdate.push_back(std::make_pair(MBBI++, Reg+i)); - } } ConstantsOut.clear(); |