Commit 93b0536f authored by Sjoerd Meijer's avatar Sjoerd Meijer
Browse files

[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
parent 0a8cae10
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;

+3 −1
Original line number Diff line number Diff line
@@ -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;
}