[PATCH] D111028: [BasicAA] Ignore CanBeFreed in minimal extent reasoning

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 4 13:09:09 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG30001af84ec5: [BasicAA] Ignore CanBeFreed in minimal extent reasoning (authored by nikic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111028

Files:
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/test/Analysis/BasicAA/dereferenceable.ll


Index: llvm/test/Analysis/BasicAA/dereferenceable.ll
===================================================================
--- llvm/test/Analysis/BasicAA/dereferenceable.ll
+++ llvm/test/Analysis/BasicAA/dereferenceable.ll
@@ -1,4 +1,5 @@
 ; RUN: opt -basic-aa -print-all-alias-modref-info -aa-eval < %s 2>&1 | FileCheck %s
+; RUN: opt -basic-aa -print-all-alias-modref-info -aa-eval -use-dereferenceable-at-point-semantics=1 < %s 2>&1 | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -204,12 +204,12 @@
                                      bool NullIsValidLoc) {
   // If we have dereferenceability information we know a lower bound for the
   // extent as accesses for a lower offset would be valid. We need to exclude
-  // the "or null" part if null is a valid pointer.
+  // the "or null" part if null is a valid pointer. We can ignore frees, as an
+  // access after free would be undefined behavior.
   bool CanBeNull, CanBeFreed;
   uint64_t DerefBytes =
     V.getPointerDereferenceableBytes(DL, CanBeNull, CanBeFreed);
   DerefBytes = (CanBeNull && NullIsValidLoc) ? 0 : DerefBytes;
-  DerefBytes = CanBeFreed ? 0 : DerefBytes;
   // If queried with a precise location size, we assume that location size to be
   // accessed, thus valid.
   if (LocSize.isPrecise())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111028.377015.patch
Type: text/x-patch
Size: 1515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211004/8940dcd8/attachment.bin>


More information about the llvm-commits mailing list