diff options
| author | Jessica Paquette <jpaquette@apple.com> | 2017-12-07 21:51:43 +0000 |
|---|---|---|
| committer | Jessica Paquette <jpaquette@apple.com> | 2017-12-07 21:51:43 +0000 |
| commit | 59948666fb9a5892395a06fd5ee801354ce1c5cd (patch) | |
| tree | c76438586fa9f5adb5374d0bcaf24b8daead81d0 /llvm/lib/Target/AArch64 | |
| parent | 5b6c0f75e01571851b767dc63a3229c962f464f1 (diff) | |
| download | bcm5719-llvm-59948666fb9a5892395a06fd5ee801354ce1c5cd.tar.gz bcm5719-llvm-59948666fb9a5892395a06fd5ee801354ce1c5cd.zip | |
[MachineOutliner] Fix offset overflow check
The offset overflow check before was incorrect. It would always give the
correct result, but it was comparing the SCALED potential fixed-up offset
against an UNSCALED minimum/maximum. As a result, the outliner was missing a
bunch of frame setup/destroy instructions that ought to have been safe to
outline. This fixes that, and adds an instruction to the .mir test that
failed the old test.
llvm-svn: 320090
Diffstat (limited to 'llvm/lib/Target/AArch64')
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index b88beda4d6b..9e12b1a0e70 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -4833,15 +4833,17 @@ AArch64InstrInfo::getOutliningType(MachineInstr &MI) const { // Find the minimum/maximum offset for this instruction and check if // fixing it up would be in range. - int64_t MinOffset, MaxOffset; - unsigned DummyScale; - getMemOpInfo(MI.getOpcode(), DummyScale, DummyWidth, MinOffset, + int64_t MinOffset, MaxOffset; // Unscaled offsets for the instruction. + unsigned Scale; // The scale to multiply the offsets by. + getMemOpInfo(MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset); // TODO: We should really test what happens if an instruction overflows. // This is tricky to test with IR tests, but when the outliner is moved // to a MIR test, it really ought to be checked. - if (Offset + 16 < MinOffset || Offset + 16 > MaxOffset) + + Offset += 16; // Update the offset to what it would be if we outlined. + if (Offset < MinOffset * Scale || Offset > MaxOffset * Scale) return MachineOutlinerInstrType::Illegal; // It's in range, so we can outline it. |

