@@ -31,9 +31,9 @@ InstrBuilder::InstrBuilder(const llvm::MCSubtargetInfo &sti,
3131 const llvm::MCInstrInfo &mcii,
3232 const llvm::MCRegisterInfo &mri,
3333 const llvm::MCInstrAnalysis *mcia,
34- const mca::InstrumentManager &im)
34+ const mca::InstrumentManager &im, unsigned cl )
3535 : STI(sti), MCII(mcii), MRI(mri), MCIA(mcia), IM(im), FirstCallInst(true ),
36- FirstReturnInst (true ) {
36+ FirstReturnInst (true ), CallLatency(cl) {
3737 const MCSchedModel &SM = STI.getSchedModel ();
3838 ProcResourceMasks.resize (SM.getNumProcResourceKinds ());
3939 computeProcResourceMasks (STI.getSchedModel (), ProcResourceMasks);
@@ -220,17 +220,19 @@ static void initializeUsedResources(InstrDesc &ID,
220220
221221static void computeMaxLatency (InstrDesc &ID, const MCInstrDesc &MCDesc,
222222 const MCSchedClassDesc &SCDesc,
223- const MCSubtargetInfo &STI) {
223+ const MCSubtargetInfo &STI,
224+ unsigned CallLatency) {
224225 if (MCDesc.isCall ()) {
225226 // We cannot estimate how long this call will take.
226- // Artificially set an arbitrarily high latency (100cy) .
227- ID.MaxLatency = 100U ;
227+ // Artificially set an arbitrarily high latency.
228+ ID.MaxLatency = CallLatency ;
228229 return ;
229230 }
230231
231232 int Latency = MCSchedModel::computeInstrLatency (STI, SCDesc);
232- // If latency is unknown, then conservatively assume a MaxLatency of 100cy.
233- ID.MaxLatency = Latency < 0 ? 100U : static_cast <unsigned >(Latency);
233+ // If latency is unknown, then conservatively assume the MaxLatency set for
234+ // calls.
235+ ID.MaxLatency = Latency < 0 ? CallLatency : static_cast <unsigned >(Latency);
234236}
235237
236238static Error verifyOperands (const MCInstrDesc &MCDesc, const MCInst &MCI) {
@@ -568,7 +570,7 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI,
568570 // We don't correctly model calls.
569571 WithColor::warning () << " found a call in the input assembly sequence.\n " ;
570572 WithColor::note () << " call instructions are not correctly modeled. "
571- << " Assume a latency of 100cy .\n " ;
573+ << " Assume a latency of " << CallLatency << " cy .\n " ;
572574 FirstCallInst = false ;
573575 }
574576
@@ -580,7 +582,7 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI,
580582 }
581583
582584 initializeUsedResources (*ID, SCDesc, STI, ProcResourceMasks);
583- computeMaxLatency (*ID, MCDesc, SCDesc, STI);
585+ computeMaxLatency (*ID, MCDesc, SCDesc, STI, CallLatency );
584586
585587 if (Error Err = verifyOperands (MCDesc, MCI))
586588 return std::move (Err);
0 commit comments