[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 13:31:03 PDT 2018
trixirt updated this revision to Diff 161551.
trixirt added a comment.
Changes suggested by Craig.
For readability, move chooseBestLEA's variables closer to call.
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
@@ -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.161551.patch
Type: text/x-patch
Size: 840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180820/f9589675/attachment.bin>
More information about the llvm-commits
mailing list