[PATCH] D50780: Check that the key is in the LEAs map before accessing

Tom Rix via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 20 07:11:12 PDT 2018


trixirt updated this revision to Diff 161476.
trixirt added a comment.

Switch to using 'find' as suggested by Craig


Repository:
  rL LLVM

https://reviews.llvm.org/D50780

Files:
  lib/Target/X86/X86OptimizeLEAs.cpp


Index: lib/Target/X86/X86OptimizeLEAs.cpp
===================================================================
--- lib/Target/X86/X86OptimizeLEAs.cpp
+++ lib/Target/X86/X86OptimizeLEAs.cpp
@@ -514,8 +514,14 @@
     MachineInstr *DefMI;
     int64_t AddrDispShift;
     int Dist;
-    if (!chooseBestLEA(LEAs[getMemOpKey(MI, MemOpNo)], MI, DefMI, AddrDispShift,
-                       Dist))
+    MemOpKey key = getMemOpKey(MI, MemOpNo);
+    auto insns = LEAs.find(key);
+
+    // Do not call chooseBestLEA if there was no matching LEA
+    if (insns == LEAs.end())
+      continue;
+
+    if (!chooseBestLEA(insns->second, MI, DefMI, AddrDispShift, Dist))
       continue;
 
     // If LEA occurs before current instruction, we can freely replace


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50780.161476.patch
Type: text/x-patch
Size: 748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180820/324c9b40/attachment.bin>


More information about the llvm-commits mailing list