diff options
Diffstat (limited to 'llvm/lib/Analysis/MemoryBuiltins.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemoryBuiltins.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index 57b9799..6b7a3e1 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -838,11 +838,14 @@ OffsetSpan ObjectSizeOffsetVisitor::computeImpl(Value *V) { // We end up pointing on a location that's outside of the original object. if (ORT.knownBefore() && ORT.Before.isNegative()) { - // This is UB, and we'd rather return an empty location then. + // This means that we *may* be accessing memory before the allocation. + // Conservatively return an unknown size. + // + // TODO: working with ranges instead of value would make it possible to take + // a better decision. if (Options.EvalMode == ObjectSizeOpts::Mode::Min || Options.EvalMode == ObjectSizeOpts::Mode::Max) { - ORT.Before = APInt::getZero(ORT.Before.getBitWidth()); - ORT.After = APInt::getZero(ORT.Before.getBitWidth()); + return ObjectSizeOffsetVisitor::unknown(); } // Otherwise it's fine, caller can handle negative offset. } |