[PATCH] Fix SROA regression causing data corruption, fixes PR19250
Björn Steinbrink
bsteinbr at gmail.com
Mon Jun 16 15:16:49 PDT 2014
Fix SROA regression causing miscompilation, fixes PR19250
Summary:
r199771 accidently changed the logic that excludes integer types that
are not a byte width multiple from being used as the type used for a
newly formed partition.
This means that we can, for example, end up with a partition that spans
a single byte and has two users, one load with type i1 and another one
with type i32. The latter is considered to be splittable and expands
beyond the partition.
Now in findCommonType, i1 is assigned to Ty before the check that
rejects i1 because its width is not a byte width multiple. And because
it is the only type that spans the whole partition, TyIsCommon remains
true and i1 is returned as the common type.
Since such types are not actually supported, this causes some bits to be
zeroed out in the load of the i32 value, because the first byte gets
truncated to i1 and then zero-extended.
To fix this problem, we must make sure to check for non-byte width types
first and always reject them.
Reviewers: dexonsmith
Cc: aprantl
Differential Revision: http://reviews.llvm.org/D3297
http://reviews.llvm.org/D3297
Files:
lib/Transforms/Scalar/SROA.cpp
test/Transforms/SROA/order_independence.ll
test/Transforms/SROA/slicewidth.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3297.10463.patch
Type: text/x-patch
Size: 3724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140616/00a1c515/attachment.bin>
More information about the llvm-commits
mailing list