[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.

llvm-svn: 357528
This commit is contained in:
Craig Topper 2019-04-02 20:52:10 +00:00
parent b64f915ae0
commit ffd8662558

View File

@ -153,6 +153,12 @@ FixupLEAPass::postRAConvertToLEA(MachineFunction::iterator &MFI,
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: