1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[RDA] getInstFromId: find instructions. NFC.

To find the instruction in the block for a given ID, first a count and then a
lookup was performed in the map, which is almost the same thing, thus doing
double the work.

Differential Revision: https://reviews.llvm.org/D73866
This commit is contained in:
Sjoerd Meijer 2020-02-06 14:13:31 +00:00
parent a02c477d91
commit 38be4f1e91
2 changed files with 4 additions and 2 deletions

View File

@ -55,7 +55,7 @@ private:
/// The first instruction in each basic block is 0.
int CurInstr;
/// Maps instructions to their instruction Ids, relative to the begining of
/// Maps instructions to their instruction Ids, relative to the beginning of
/// their basic blocks.
DenseMap<MachineInstr *, int> InstIds;

View File

@ -215,9 +215,11 @@ MachineInstr *ReachingDefAnalysis::getInstFromId(MachineBasicBlock *MBB,
return nullptr;
for (auto &MI : *MBB) {
if (InstIds.count(&MI) && InstIds.lookup(&MI) == InstId)
auto F = InstIds.find(&MI);
if (F != InstIds.end() && F->second == InstId)
return &MI;
}
return nullptr;
}