Skip to content

[X86] Avoid repeated hash lookups (NFC) #131725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions llvm/lib/Target/X86/X86PadShortFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,9 @@ void PadShortFunc::findReturns(MachineBasicBlock *MBB, unsigned int Cycles) {
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;
auto [It, Inserted] = VisitedBBs.try_emplace(MBB);
if (!Inserted) {
VisitedBBInfo BBInfo = It->second;
Cycles += BBInfo.Cycles;
return BBInfo.HasReturn;
}
Expand All @@ -196,15 +195,15 @@ bool PadShortFunc::cyclesUntilReturn(MachineBasicBlock *MBB,
// functions do not count because the called function will be padded,
// if necessary.
if (MI.isReturn() && !MI.isCall()) {
VisitedBBs[MBB] = VisitedBBInfo(true, CyclesToEnd);
It->second = VisitedBBInfo(true, CyclesToEnd);
Cycles += CyclesToEnd;
return true;
}

CyclesToEnd += TSM.computeInstrLatency(&MI);
}

VisitedBBs[MBB] = VisitedBBInfo(false, CyclesToEnd);
It->second = VisitedBBInfo(false, CyclesToEnd);
Cycles += CyclesToEnd;
return false;
}
Expand Down