[PATCH] D156510: [ValueTracking] Dereferenceable ret attributes implys noundef
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 00:05:57 PDT 2023
StephenFan created this revision.
StephenFan added a reviewer: nikic.
Herald added subscribers: okura, kuter, hiraditya.
Herald added a project: All.
StephenFan requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156510
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/Attributor/memory_locations.ll
llvm/test/Transforms/Attributor/value-simplify.ll
Index: llvm/test/Transforms/Attributor/value-simplify.ll
===================================================================
--- llvm/test/Transforms/Attributor/value-simplify.ll
+++ llvm/test/Transforms/Attributor/value-simplify.ll
@@ -437,7 +437,7 @@
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_inalloca
; CGSCC-SAME: (ptr nofree noundef nonnull readnone dereferenceable(4) [[ARG:%.*]]) #[[ATTR2]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call noalias nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree noundef nonnull writeonly inalloca(i32) dereferenceable(4) [[ARG]]) #[[ATTR13]]
+; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree noundef nonnull writeonly inalloca(i32) dereferenceable(4) [[ARG]]) #[[ATTR13]]
; CGSCC-NEXT: ret ptr [[CALL]]
;
%call = call ptr @test_inalloca(ptr inalloca(i32) %arg)
Index: llvm/test/Transforms/Attributor/memory_locations.ll
===================================================================
--- llvm/test/Transforms/Attributor/memory_locations.ll
+++ 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:
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -6598,7 +6598,9 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156510.545029.patch
Type: text/x-patch
Size: 2222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/620932c4/attachment.bin>
More information about the llvm-commits
mailing list