[aarch64][globalisel] Fix a crash in selectAddrModeIndexed() caused by incorrect G_FRAME_INDEX handling

The wrong operand was being rendered to the result instruction.

The crash was detected by Bitcode/simd_ops/AArch64_halide_runtime.bc

llvm-svn: 315890
This commit is contained in:
Daniel Sanders 2017-10-16 05:39:30 +00:00
parent 6621cf67cf
commit 01805b6747
1 changed files with 5 additions and 1 deletions

View File

@ -1497,7 +1497,11 @@ AArch64InstructionSelector::selectAddrModeIndexed(MachineOperand &Root,
unsigned Scale = Log2_32(Size);
if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 && RHSC < (0x1000 << Scale)) {
if (LHSDef->getOpcode() == TargetOpcode::G_FRAME_INDEX)
LHSDef = MRI.getVRegDef(LHSDef->getOperand(1).getReg());
return {{
[=](MachineInstrBuilder &MIB) { MIB.add(LHSDef->getOperand(1)); },
[=](MachineInstrBuilder &MIB) { MIB.addImm(RHSC >> Scale); },
}};
return {{
[=](MachineInstrBuilder &MIB) { MIB.add(LHS); },
[=](MachineInstrBuilder &MIB) { MIB.addImm(RHSC >> Scale); },