summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 396690e1860..ef4cc227222 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -188,8 +188,12 @@ static bool canTransformToMemCmp(CallInst *CI, Value *Str, uint64_t Len,
static void annotateDereferenceableBytes(CallInst *CI,
ArrayRef<unsigned> ArgNos,
- uint64_t DerefBytes) {
+ uint64_t DereferenceableBytes) {
for (unsigned ArgNo : ArgNos) {
+ uint64_t DerefBytes = std::max(
+ CI->getDereferenceableOrNullBytes(ArgNo + AttributeList::FirstArgIndex),
+ DereferenceableBytes);
+
if (CI->getDereferenceableBytes(ArgNo + AttributeList::FirstArgIndex) <
DerefBytes) {
CI->removeParamAttr(ArgNo, Attribute::Dereferenceable);
OpenPOWER on IntegriCloud