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

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 22 11:25:04 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL340434: [X86] In OptimizeLEAs pass, check that the key is in the LEAs map beforeā€¦ (authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50780?vs=161551&id=162008#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50780

Files:
  llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp


Index: llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp
+++ llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp
@@ -510,12 +510,16 @@
 
     MemOpNo += X86II::getOperandBias(Desc);
 
+    // Do not call chooseBestLEA if there was no matching LEA
+    auto Insns = LEAs.find(getMemOpKey(MI, MemOpNo));
+    if (Insns == LEAs.end())
+      continue;
+
     // Get the best LEA instruction to replace address calculation.
     MachineInstr *DefMI;
     int64_t AddrDispShift;
     int Dist;
-    if (!chooseBestLEA(LEAs[getMemOpKey(MI, MemOpNo)], MI, DefMI, AddrDispShift,
-                       Dist))
+    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.162008.patch
Type: text/x-patch
Size: 873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/49b7979a/attachment.bin>


More information about the llvm-commits mailing list