[PATCH] D117084: [CFLGraph] Change isMallocOrCallocLikeFn to isNoAliasCall now that allocation functions must be marked noalias

Bryce Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 11 22:22:16 PST 2022


Bryce-MW updated this revision to Diff 399208.
Bryce-MW added a comment.

- Rebase to fix failing test on Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117084

Files:
  llvm/lib/Analysis/CFLGraph.h


Index: llvm/lib/Analysis/CFLGraph.h
===================================================================
--- llvm/lib/Analysis/CFLGraph.h
+++ llvm/lib/Analysis/CFLGraph.h
@@ -429,12 +429,10 @@
       if (Call.getType()->isPointerTy())
         addNode(&Call);
 
-      // Check if Inst is a call to a library function that
-      // allocates/deallocates on the heap. Those kinds of functions do not
-      // introduce any aliases.
-      // TODO: address other common library functions such as realloc(),
-      // strdup(), etc.
-      if (isMallocOrCallocLikeFn(&Call, &TLI) || isFreeCall(&Call, &TLI))
+      // Check if Inst is a call to a function that is annotated noalias
+      // (including allocation functions) or a library function that frees
+      // memory. Those kinds of functions do not introduce any aliases.
+      if (isNoAliasCall(&Call) || isFreeCall(&Call, &TLI))
         return;
 
       // TODO: Add support for noalias args/all the other fun function
@@ -461,11 +459,11 @@
         }
 
       if (Call.getType()->isPointerTy()) {
-        auto *Fn = Call.getCalledFunction();
-        if (Fn == nullptr || !Fn->returnDoesNotAlias())
-          // No need to call addNode() since we've added Inst at the
-          // beginning of this function and we know it is not a global.
-          Graph.addAttr(InstantiatedValue{&Call, 0}, getAttrUnknown());
+        // Since we checked isNoAliasCall and returned early if true, we don't
+        // need to confirm that it is false now.
+        // No need to call addNode() since we've added Inst at the
+        // beginning of this function and we know it is not a global.
+        Graph.addAttr(InstantiatedValue{&Call, 0}, getAttrUnknown());
       }
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117084.399208.patch
Type: text/x-patch
Size: 1736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220112/07f858f3/attachment.bin>


More information about the llvm-commits mailing list