llvm-project/llvm/test/Analysis/ValueTracking
Florian Hahn 7902405c42 [ValueTracking] Fix a misuse of APInt in GetPointerBaseWithConstantOffset
GetPointerBaseWithConstantOffset include this code, where ByteOffset
and GEPOffset are both of type llvm::APInt :

  ByteOffset += GEPOffset.getSExtValue();

The problem with this line is that getSExtValue() returns an int64_t, but
the += matches an overload for uint64_t. The problem is that the resulting
APInt is no longer considered to be signed. That in turn causes assertion
failures later on if the relevant pointer type is > 64 bits in width and
the GEPOffset was negative.

Changing it to

  ByteOffset += GEPOffset.sextOrTrunc(ByteOffset.getBitWidth());

resolves the issue and explicitly performs the sign-extending
or truncation. Additionally, instead of asserting later if the result
is > 64 bits, it breaks out of the loop in that case.

See also
 https://reviews.llvm.org/D24729
 https://reviews.llvm.org/D24772

This commit must be merged after D38662 in order for the test to pass.

Patch by Michael Ferguson <mpfergu@gmail.com>.

Reviewers: reames, sanjoy, hfinkel

Reviewed By: hfinkel

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

llvm-svn: 350395
2019-01-04 14:53:22 +00:00
..
assume.ll [ValueTracking] Don't delete assumes of side-effectful instructions 2017-08-14 17:11:43 +00:00
deref-bitcast-of-gep.ll Propagate nonnull and dereferenceable throught launder 2018-05-18 23:54:33 +00:00
dereferenceable-and-aligned.ll
func-ptr-lsb.ll [IR] Do not assume that function pointers are aligned 2018-04-27 09:12:12 +00:00
gep-negative-issue.ll [ValueTracking] Fix a misuse of APInt in GetPointerBaseWithConstantOffset 2019-01-04 14:53:22 +00:00
get-pointer-base-with-const-off.ll
invariant.group.ll Simplify recursive launder.invariant.group and strip 2018-07-12 23:55:20 +00:00
known-bits-from-range-md.ll
known-non-equal.ll
known-nonnull-at.ll Fix aliasing of launder.invariant.group 2018-05-23 09:16:44 +00:00
known-power-of-two.ll
known-signbit-shift.ll [ValueTracking] return zero when there's conflict in known bits of a shift (PR34838) 2017-10-12 17:31:46 +00:00
knownnonzero-shift.ll
knownzero-addrspacecast.ll
knownzero-shift.ll
memory-dereferenceable.ll Give up on array allocas in getPointerDereferenceableBytes 2017-12-20 10:01:30 +00:00
monotonic-phi.ll
non-negative-phi-bits.ll InstCombine: move hasOneUse check to the top of foldICmpAddConstant 2018-09-10 14:26:44 +00:00
numsignbits-from-assume.ll Fix llvm::ComputeNumSignBits with some operations and llvm.assume 2018-07-25 16:39:24 +00:00
pr23011.ll
select-pattern.ll [ValueTracking] add recursion depth param to matchSelectPattern 2018-01-24 15:20:37 +00:00
signbits-extract-elt.ll