[llvm] 4e84ec8 - [ValueTracking] Dereferenceable ret attributes implys noundef
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 7 00:11:59 PDT 2023
Author: luxufan
Date: 2023-08-07T15:11:03+08:00
New Revision: 4e84ec818439a18cca185ca04afad80f5ae023e2
URL: https://github.com/llvm/llvm-project/commit/4e84ec818439a18cca185ca04afad80f5ae023e2
DIFF: https://github.com/llvm/llvm-project/commit/4e84ec818439a18cca185ca04afad80f5ae023e2.diff
LOG: [ValueTracking] Dereferenceable ret attributes implys noundef
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D156510
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/Attributor/memory_locations.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index f8aa72605a7c21..6bffab61d01479 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -6757,7 +6757,9 @@ static bool isGuaranteedNotToBeUndefOrPoison(const Value *V,
return true;
if (const auto *CB = dyn_cast<CallBase>(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
index ec1d7d46aef4d8..71d6223a986b6d 100644
--- a/llvm/test/Transforms/Attributor/memory_locations.ll
+++ b/llvm/test/Transforms/Attributor/memory_locations.ll
@@ -195,7 +195,7 @@ define dso_local ptr @internal_argmem_only_write(ptr %arg) {
; 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:
More information about the llvm-commits
mailing list