[llvm] 93b0536 - [RDA] getInstFromId: find instructions. NFC.

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 6 06:17:09 PST 2020


Author: Sjoerd Meijer
Date: 2020-02-06T14:13:31Z
New Revision: 93b0536fd2af8a7a0be6cebd0f768a89d64cac30

URL: https://github.com/llvm/llvm-project/commit/93b0536fd2af8a7a0be6cebd0f768a89d64cac30
DIFF: https://github.com/llvm/llvm-project/commit/93b0536fd2af8a7a0be6cebd0f768a89d64cac30.diff

LOG: [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

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
    llvm/lib/CodeGen/ReachingDefAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
index 3f2f93cb00c7..c889f3c6d4ae 100644
--- a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
+++ b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
@@ -55,7 +55,7 @@ class ReachingDefAnalysis : public MachineFunctionPass {
   /// 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;
 

diff  --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index 62adaaf419df..03122ae75670 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -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;
 }
 


        


More information about the llvm-commits mailing list