[Inline] Fix in handling of ptrtoint in InlineCost
authorMikael Holmen <mikael.holmen@ericsson.com>
Mon, 23 Nov 2020 12:15:10 +0000 (13:15 +0100)
committerMikael Holmen <mikael.holmen@ericsson.com>
Mon, 23 Nov 2020 13:33:06 +0000 (14:33 +0100)
commitfaf848ac321801ba92b1d3038fccc84988d46ac8
tree4fc13f47f4ee21acdba3851418825f3756ac6654
parenta8f6f4e8733cd601246ddc3e391cd82236231846
[Inline] Fix in handling of ptrtoint in InlineCost

ConstantOffsetPtrs contains mappings from a Value to a base pointer and
an offset. The offset is typed and has a size, and at least when dealing
with ptrtoint, it could happen that we had a mapping from a ptrtoint
with type i32 to an offset with type i16. This could later cause
problems, showing up in PR 47969 and PR 38500.

In PR 47969 we ended up in an assert complaining that trunc i16 to i16
is invalid and in Pr 38500 that a cmp on an i32 and i16 value isn't
valid.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D90610
llvm/lib/Analysis/InlineCost.cpp
llvm/test/Transforms/Inline/inline-ptrtoint-different-sizes.ll [new file with mode: 0644]