[llvm] r357528 - [X86] Check MI.isConvertibleTo3Addr() before calling convertToThreeAddress in X86FixupLEAs.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 2 13:52:10 PDT 2019
Author: ctopper
Date: Tue Apr 2 13:52:10 2019
New Revision: 357528
URL: http://llvm.org/viewvc/llvm-project?rev=357528&view=rev
Log:
[X86] Check MI.isConvertibleTo3Addr() before calling convertToThreeAddress in X86FixupLEAs.
X86FixupLEAs just assumes convertToThreeAddress will return nullptr for any instruction that isn't convertible.
But the code in convertToThreeAddress for X86 assumes that any instruction coming in has at least 2 operands and that the second one is a register. But those properties aren't guaranteed of all instructions. We should check the instruction property first.
Modified:
llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp
Modified: llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp?rev=357528&r1=357527&r2=357528&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FixupLEAs.cpp Tue Apr 2 13:52:10 2019
@@ -153,6 +153,12 @@ FixupLEAPass::postRAConvertToLEA(Machine
MFI->insert(MBBI, NewMI); // Insert the new inst
return NewMI;
}
+ }
+
+ if (!MI.isConvertibleTo3Addr())
+ return nullptr;
+
+ switch (MI.getOpcode()) {
case X86::ADD64ri32:
case X86::ADD64ri8:
case X86::ADD64ri32_DB:
More information about the llvm-commits
mailing list