[DSE] Bugfix to avoid PartialStoreMerging involving non byte-sized stores
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Fri, 24 May 2019 08:32:02 +0000 (08:32 +0000)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Fri, 24 May 2019 08:32:02 +0000 (08:32 +0000)
commitd63a2bb35fb25ca17b3cb6e82bcb2050179381b0
tree28e24d0443d0c3bd8d7c9f92a7f83132af27c472
parent937af54666c4f4f1cb332bb28cecc86d0e1c5de1
[DSE] Bugfix to avoid PartialStoreMerging involving non byte-sized stores

Summary:
The DeadStoreElimination pass now skips doing
PartialStoreMerging when stores overlap according to
OW_PartialEarlierWithFullLater and at least one of
the stores is having a store size that is different
from the size of the type being stored.

This solves problems seen in
  https://bugs.llvm.org/show_bug.cgi?id=41949
for which we in the past could end up with
mis-compiles or assertions.

The content and location of the padding bits is not
formally described (or undefined) in the LangRef
at the moment. So the solution is chosen based on
that we cannot assume anything about the padding bits
when having a store that clobbers more memory than
indicated by the type of the value that is stored
(such as storing an i6 using an 8-bit store instruction).

Fixes: https://bugs.llvm.org/show_bug.cgi?id=41949

Reviewers: spatel, efriedma, fhahn

Reviewed By: efriedma

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 361605
llvm/include/llvm/IR/DataLayout.h
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/PartialStore2.ll [new file with mode: 0644]