[llvm] [FunctionAttrs] Bail if initializes range overflows 64-bit signed int (PR #137053)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 14:01:25 PDT 2025
================
@@ -661,8 +661,12 @@ ArgumentAccessInfo getArgumentAccessInfo(const Instruction *I,
auto TypeSize = DL.getTypeStoreSize(Ty);
if (!TypeSize.isScalable() && Offset) {
int64_t Size = TypeSize.getFixedValue();
- return ConstantRange(APInt(64, *Offset, true),
- APInt(64, *Offset + Size, true));
+ APInt Low(64, *Offset, true);
+ APInt High(64, *Offset + Size, true);
+ // Bail if the range overflows signed 64-bit int.
+ if (Low.sge(High))
+ return std::nullopt;
+ return ConstantRange(Low, High);
----------------
aeubanks wrote:
I didn't see this, thanks for pointing it out. Although I ended up just using `APInt::sadd_ov`
https://github.com/llvm/llvm-project/pull/137053
More information about the llvm-commits
mailing list