AArch64: Remove reversedInstructionsWithoutDebug helper
authorVedant Kumar <vsk@apple.com>
Fri, 24 Apr 2020 18:16:43 +0000 (11:16 -0700)
committerVedant Kumar <vsk@apple.com>
Fri, 24 Apr 2020 18:28:17 +0000 (11:28 -0700)
commitc0fa447e02c4cd8c53c3ab03efa6391175e3d56e
tree932f899954c11da07311e363fe56c0d722d0acda
parentef423a3ba57045f80b0fcafce72121449a8b54d4
AArch64: Remove reversedInstructionsWithoutDebug helper

When using reversedInstructionsWithoutDebug to construct a range from a
pair of MachineInstrBundleIterators, the range unexpectedly leaves out an
element. This results in mis-optimization as @mstorsjo points out in
https://reviews.llvm.org/D78157.

The problem is that when we convert a MachineInstrBundleIterator to a
reverse iterator, the result gets incremented:

  MachineInstrBundleIterator(++I.getReverse())

The comment there explains that the "resulting iterator will dereference
... to the previous node, which is somewhat unexpected; but converting
the two endpoints in a range will give the same range in reverse". This
makes it hard to understand what reversedInstructionsWithoutDebug will
do: I've removed the helper to prevent similar mistakes in the future.
llvm/include/llvm/CodeGen/MachineBasicBlock.h
llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/peephole-opt-check-cflags.mir [new file with mode: 0644]