[llvm] [FunctionAttrs] Infer noalias through a null check. (PR #226956)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 04:06:50 PDT 2026


================
@@ -1485,7 +1485,11 @@ static bool isFunctionMallocLike(Function *F, const SCCNodeSet &SCCNodes) {
         return false; // Did not come from an allocation.
       }
 
-    if (PointerMayBeCaptured(RetVal, /*ReturnCaptures=*/false))
+    // Checking if result is null does not prevent it from being noalias.
+    if (capturesAnything(
+            PointerMayBeCaptured(RetVal, CaptureComponents::All &
+                                             ~CaptureComponents::AddressIsNull)
----------------
nikic wrote:

Why only AddressIsNull? Other address captures shouldn't matter for noalias either, right?

https://github.com/llvm/llvm-project/pull/226956


More information about the llvm-commits mailing list