-bool PadShortFunc::cyclesUntilReturn(MachineFunction &MF,
- MachineBasicBlock &MBB,
- unsigned int &Cycles,
- MachineBasicBlock::iterator *Location)
-{
- const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
- const TargetMachine &Target = MF.getTarget();
-
- for (MachineBasicBlock::iterator MBBI = MBB.begin(); MBBI != MBB.end();
- ++MBBI) {
+bool PadShortFunc::cyclesUntilReturn(MachineBasicBlock *MBB,
+ unsigned int &Cycles) {
+ // Return cached result if BB was previously visited
+ DenseMap<MachineBasicBlock*, VisitedBBInfo>::iterator it
+ = VisitedBBs.find(MBB);
+ if (it != VisitedBBs.end()) {
+ VisitedBBInfo BBInfo = it->second;
+ Cycles += BBInfo.Cycles;
+ return BBInfo.HasReturn;
+ }
+
+ unsigned int CyclesToEnd = 0;
+
+ for (MachineBasicBlock::iterator MBBI = MBB->begin();
+ MBBI != MBB->end(); ++MBBI) {