Allow MachineTraceMetrics to be used when the model has no resources.

It it still possible to extract information from itineraries, for
example.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178582 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2013-04-02 22:27:45 +00:00
parent d0a0757c3b
commit 2ccdbc6675
2 changed files with 11 additions and 7 deletions

View File

@ -677,10 +677,6 @@ bool EarlyIfConverter::shouldConvertIf() {
if (Stress)
return true;
// Without a scheduling model, we can't make decisions.
if (!SchedModel->hasInstrSchedModel())
return false;
if (!MinInstr)
MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount);

View File

@ -105,6 +105,8 @@ MachineTraceMetrics::getResources(const MachineBasicBlock *MBB) {
FBI->HasCalls = true;
// Count processor resources used.
if (!SchedModel.hasInstrSchedModel())
continue;
const MCSchedClassDesc *SC = SchedModel.resolveSchedClass(MI);
if (!SC->isValid())
continue;
@ -132,7 +134,9 @@ MachineTraceMetrics::getProcResourceCycles(unsigned MBBNum) const {
assert(BlockInfo[MBBNum].hasResources() &&
"getResources() must be called before getProcResourceCycles()");
unsigned PRKinds = SchedModel.getNumProcResourceKinds();
return ArrayRef<unsigned>(&ProcResourceCycles[MBBNum * PRKinds], PRKinds);
assert((MBBNum+1) * PRKinds <= ProcResourceCycles.size());
return ArrayRef<unsigned>(ProcResourceCycles.data() + MBBNum * PRKinds,
PRKinds);
}
@ -251,7 +255,9 @@ ArrayRef<unsigned>
MachineTraceMetrics::Ensemble::
getProcResourceDepths(unsigned MBBNum) const {
unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
return ArrayRef<unsigned>(&ProcResourceDepths[MBBNum * PRKinds], PRKinds);
assert((MBBNum+1) * PRKinds <= ProcResourceDepths.size());
return ArrayRef<unsigned>(ProcResourceDepths.data() + MBBNum * PRKinds,
PRKinds);
}
/// Get an array of processor resource heights for MBB. Indexed by processor
@ -263,7 +269,9 @@ ArrayRef<unsigned>
MachineTraceMetrics::Ensemble::
getProcResourceHeights(unsigned MBBNum) const {
unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
return ArrayRef<unsigned>(&ProcResourceHeights[MBBNum * PRKinds], PRKinds);
assert((MBBNum+1) * PRKinds <= ProcResourceHeights.size());
return ArrayRef<unsigned>(ProcResourceHeights.data() + MBBNum * PRKinds,
PRKinds);
}
//===----------------------------------------------------------------------===//