[PATCH] D117180: [BasicAliasAnalysis] Switch from isMallocOrCallocLikeFn to onlyAccessesInaccessibleMemory

Bryce Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 12 19:27:59 PST 2022


Bryce-MW created this revision.
Herald added subscribers: jeroen.dobbelaere, hiraditya.
Bryce-MW requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Allocation functions should be marked correctly with onlyAccessesInaccessibleMemory so this change can be made (assuming the comment was accurate). In the future, this could be expanded to check inaccessiblememorargmemonly as well but that would have to ensure that the args don't alias with the memory location in question.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117180

Files:
  llvm/lib/Analysis/BasicAliasAnalysis.cpp


Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -996,13 +996,9 @@
     }
   }
 
-  // If the call is malloc/calloc like, we can assume that it doesn't
-  // modify any IR visible value.  This is only valid because we assume these
-  // routines do not read values visible in the IR.  TODO: Consider special
-  // casing realloc and strdup routines which access only their arguments as
-  // well.  Or alternatively, replace all of this with inaccessiblememonly once
-  // that's implemented fully.
-  if (isMallocOrCallocLikeFn(Call, &TLI)) {
+  // TODO: Consider using inaccessiblememorargmemonly  to allow for functions
+  // like realloc and strdup which access only their arguments as well.
+  if (Call->onlyAccessesInaccessibleMemory()) {
     // Be conservative if the accessed pointer may alias the allocation -
     // fallback to the generic handling below.
     if (getBestAAResults().alias(MemoryLocation::getBeforeOrAfter(Call), Loc,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117180.399534.patch
Type: text/x-patch
Size: 1107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/ae4ee1a3/attachment.bin>


More information about the llvm-commits mailing list