[X86] Account for partial stack slot spills (PR30821)
authorWarren Ristow <warren.ristow@sony.com>
Tue, 24 Apr 2018 22:01:50 +0000 (22:01 +0000)
committerWarren Ristow <warren.ristow@sony.com>
Tue, 24 Apr 2018 22:01:50 +0000 (22:01 +0000)
commitb960d2cb405acb23abb335145d48e37abebd0ada
tree78e557c069f111ca37c6024b77ab25062cdaafc6
parentb3bfd3b028ce99efb9e65d42a563becae3ea4ddc
[X86] Account for partial stack slot spills (PR30821)

Previously, _any_ store or load instruction was considered to be
operating on a spill if it had a frameindex as an operand, and thus
was fair game for optimisations such as "StackSlotColoring". This
usually works, except on architectures where spills can be partially
restored, for example on X86 where a spilt vector can have a single
component loaded (zeroing the rest of the target register). This can be
mis-interpreted and the zero extension unsoundly eliminated, see
pr30821.

To avoid this, this commit optionally provides the caller to
isLoadFromStackSlot and isStoreToStackSlot with the number of bytes
spilt/loaded by the given instruction. Optimisations can then determine
that a full spill followed by a partial load (or vice versa), for
example, cannot necessarily be commuted.

Patch by Jeremy Morse!

Differential Revision: https://reviews.llvm.org/D44782

llvm-svn: 330778
llvm/include/llvm/CodeGen/TargetInstrInfo.h
llvm/lib/CodeGen/StackSlotColoring.cpp
llvm/lib/Target/X86/X86InstrInfo.cpp
llvm/lib/Target/X86/X86InstrInfo.h
llvm/test/CodeGen/X86/pr30821.mir [new file with mode: 0644]