[IC] Fix a bug with the instcombine canonicalizing of loads and
authorChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 02:30:01 +0000 (02:30 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 13 Feb 2015 02:30:01 +0000 (02:30 +0000)
commita768c4a0964ce44d1756ba4ad396773816cbf7af
tree851466796c4330f52c1e90a465240f9d39d75491
parentf491badbfca50ee7dce8101f3bbc8c0248a699c3
[IC] Fix a bug with the instcombine canonicalizing of loads and
propagating of metadata.

We were propagating !nonnull metadata even when the newly formed load is
no longer of a pointer type. This is clearly broken and results in LLVM
failing the verifier and aborting. This patch just restricts the
propagation of !nonnull metadata to when we actually have a pointer
type.

This bug report and the initial version of this patch was provided by
Charles Davis! Many thanks for finding this!

We still need to add logic to round-trip the metadata correctly if we
combine from pointer types to integer types and then back by using range
metadata for the integer type loads. But this is the minimal and safe
version of the patch, which is important so we can backport it into 3.6.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229029 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
test/Transforms/InstCombine/loadstore-metadata.ll