diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -6757,7 +6757,9 @@ return true; if (const auto *CB = dyn_cast(V)) { - if (CB->hasRetAttr(Attribute::NoUndef)) + if (CB->hasRetAttr(Attribute::NoUndef) || + CB->hasRetAttr(Attribute::Dereferenceable) || + CB->hasRetAttr(Attribute::DereferenceableOrNull)) return true; } diff --git a/llvm/test/Transforms/Attributor/memory_locations.ll b/llvm/test/Transforms/Attributor/memory_locations.ll --- a/llvm/test/Transforms/Attributor/memory_locations.ll +++ b/llvm/test/Transforms/Attributor/memory_locations.ll @@ -195,7 +195,7 @@ ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[ARG:%.*]]) #[[ATTR1]] { ; CHECK-NEXT: entry: ; CHECK-NEXT: store i32 10, ptr [[ARG]], align 4 -; CHECK-NEXT: [[CALL:%.*]] = call noalias dereferenceable_or_null(10) ptr @malloc(i64 noundef 10) +; CHECK-NEXT: [[CALL:%.*]] = call noalias noundef dereferenceable_or_null(10) ptr @malloc(i64 noundef 10) ; CHECK-NEXT: ret ptr [[CALL]] ; entry: