aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorOCHyams <orlando.hyams@sony.com>2023-05-25 10:48:22 +0100
committerOCHyams <orlando.hyams@sony.com>2023-05-31 11:17:20 +0100
commitf40e8f14d623b28d1c4632e376232f67cd58946a (patch)
tree2a696ef68162f0156d5531cf848142848b142d81 /llvm/lib/IR/DebugInfo.cpp
parentda836b36bc3540d21c947a95474d2bb6cc458951 (diff)
downloadllvm-f40e8f14d623b28d1c4632e376232f67cd58946a.zip
llvm-f40e8f14d623b28d1c4632e376232f67cd58946a.tar.gz
llvm-f40e8f14d623b28d1c4632e376232f67cd58946a.tar.bz2
[Assignment Tracking] Ignore stores to a negative offset from an alloca
Fixes crash reported in llvm.org/PR62838. Reviewed By: jryans Differential Revision: https://reviews.llvm.org/D151326
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index d2229da..0237448 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1915,7 +1915,8 @@ bool at::calculateFragmentIntersect(
}
/// Collect constant properies (base, size, offset) of \p StoreDest.
-/// Return std::nullopt if any properties are not constants.
+/// Return std::nullopt if any properties are not constants or the
+/// offset from the base pointer is negative.
static std::optional<AssignmentInfo>
getAssignmentInfoImpl(const DataLayout &DL, const Value *StoreDest,
TypeSize SizeInBits) {
@@ -1924,6 +1925,10 @@ getAssignmentInfoImpl(const DataLayout &DL, const Value *StoreDest,
APInt GEPOffset(DL.getIndexTypeSizeInBits(StoreDest->getType()), 0);
const Value *Base = StoreDest->stripAndAccumulateConstantOffsets(
DL, GEPOffset, /*AllowNonInbounds*/ true);
+
+ if (GEPOffset.isNegative())
+ return std::nullopt;
+
uint64_t OffsetInBytes = GEPOffset.getLimitedValue();
// Check for overflow.
if (OffsetInBytes == UINT64_MAX)