[PATCH] D156510: [ValueTracking] Dereferenceable ret attributes implys noundef

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 7 00:12:11 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e84ec818439: [ValueTracking] Dereferenceable ret attributes implys noundef (authored by StephenFan).

Changed prior to commit:
  https://reviews.llvm.org/D156510?vs=545029&id=547656#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156510/new/

https://reviews.llvm.org/D156510

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/Attributor/memory_locations.ll


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
@@ -6757,7 +6757,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.547656.patch
Type: text/x-patch
Size: 1240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230807/709c318a/attachment.bin>


More information about the llvm-commits mailing list