- const MachineCodeForBasicBlock& mvec = MachineCodeForBasicBlock::get(bb);
- for (unsigned i=0; i < mvec.size(); i++)
- if (! mii.isDummyPhiInstr(mvec[i]->getOpCode()))
- {
- SchedGraphNode* node = new SchedGraphNode(getNumNodes(), bb,
- mvec[i], i, target);
- this->noteGraphNodeForInstr(mvec[i], node);
-
- // Remember all register references and value defs
- findDefUseInfoAtInstr(target, node,
- memNodeVec, regToRefVecMap,valueToDefVecMap);
- }
-
-#undef REALLY_NEED_TO_SEARCH_SUCCESSOR_PHIS
-#ifdef REALLY_NEED_TO_SEARCH_SUCCESSOR_PHIS
- // This is a BIG UGLY HACK. IT NEEDS TO BE ELIMINATED.
- // Look for copy instructions inserted in this BB due to Phi instructions
- // in the successor BBs.
- // There MUST be exactly one copy per Phi in successor nodes.
- //
- for (BasicBlock::succ_const_iterator SI=bb->succ_begin(), SE=bb->succ_end();
- SI != SE; ++SI)
- for (BasicBlock::const_iterator PI=(*SI)->begin(), PE=(*SI)->end();
- PI != PE; ++PI)
- {
- if ((*PI)->getOpcode() != Instruction::PHINode)
- break; // No more Phis in this successor
-
- // Find the incoming value from block bb to block (*SI)
- int bbIndex = cast<PHINode>(*PI)->getBasicBlockIndex(bb);
- assert(bbIndex >= 0 && "But I know bb is a predecessor of (*SI)?");
- Value* inVal = cast<PHINode>(*PI)->getIncomingValue(bbIndex);
- assert(inVal != NULL && "There must be an in-value on every edge");
-
- // Find the machine instruction that makes a copy of inval to (*PI).
- // This must be in the current basic block (bb).
- const MachineCodeForVMInstr& mvec = MachineCodeForBasicBlock::get(*PI);
- const MachineInstr* theCopy = NULL;
- for (unsigned i=0; i < mvec.size() && theCopy == NULL; i++)
- if (! mii.isDummyPhiInstr(mvec[i]->getOpCode()))
- // not a Phi: assume this is a copy and examine its operands
- for (int o=0, N=(int) mvec[i]->getNumOperands(); o < N; o++)
- {
- const MachineOperand& mop = mvec[i]->getOperand(o);
-
- if (mvec[i]->operandIsDefined(o))
- assert(mop.getVRegValue() == (*PI) && "dest shd be my Phi");
-
- if (! mvec[i]->operandIsDefined(o) ||
- NOT NEEDED? mvec[i]->operandIsDefinedAndUsed(o))
- if (mop.getVRegValue() == inVal)
- { // found the copy!
- theCopy = mvec[i];
- break;
- }
- }
-
- // Found the dang instruction. Now create a node and do the rest...
- if (theCopy != NULL)
- {
- SchedGraphNode* node = new SchedGraphNode(getNumNodes(), bb,
- theCopy, origIndexInBB++, target);
- this->noteGraphNodeForInstr(theCopy, node);
- findDefUseInfoAtInstr(target, node,
- memNodeVec, regToRefVecMap,valueToDefVecMap);
- }
- }
-#endif //REALLY_NEED_TO_SEARCH_SUCCESSOR_PHIS
+ unsigned i = 0;
+ for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E;
+ ++I, ++i)
+ if (I->getOpcode() != V9::PHI) {
+ SchedGraphNode* node = new SchedGraphNode(getNumNodes(), &MBB, i, target);
+ noteGraphNodeForInstr(I, node);
+
+ // Remember all register references and value defs
+ findDefUseInfoAtInstr(target, node, memNodeVec, callDepNodeVec,
+ regToRefVecMap, valueToDefVecMap);
+ }