[llvm] [LAA] Fix implicit trunc from int64 to int and losing info (PR #139553)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 12:53:45 PDT 2025
================
@@ -1585,6 +1585,8 @@ std::optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA,
OffsetB = OffsetB.sextOrTrunc(IdxWidth);
OffsetB -= OffsetA;
+ if (OffsetB.getSignificantBits() > sizeof(int) * 8)
+ return std::nullopt;
Val = OffsetB.getSExtValue();
----------------
artagnon wrote:
> Sure, but just like for APInt, need to adjust all the users of this function to handle int64_t instead of int
Sounds like that is the right solution? `sizeof(int) * CHAR_BIT` doesn't seem like a good solution.
https://github.com/llvm/llvm-project/pull/139553
More information about the llvm-commits
mailing list