[llvm] [InferAttrs] Mark errnomem-setting libcalls as such (PR #124742)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 12:49:45 PST 2025


================
@@ -863,18 +934,23 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
     Changed |= setRetAndArgsNoUndef(F);
     Changed |= setDoesNotThrow(F);
     Changed |= setDoesNotCapture(F, 0);
+    Changed |= setOnlyAccessesInaccessibleOrArgOrErrnoMem(F, MR::Ref);
     break;
   case LibFunc_unlink:
     Changed |= setRetAndArgsNoUndef(F);
     Changed |= setDoesNotThrow(F);
     Changed |= setDoesNotCapture(F, 0);
     Changed |= setOnlyReadsMemory(F, 0);
+    Changed |=
+        setOnlyAccessesInaccessibleOrArgOrErrnoMem(F, MR::ModRef, MR::Ref);
     break;
   case LibFunc_unsetenv:
     Changed |= setRetAndArgsNoUndef(F);
     Changed |= setDoesNotThrow(F);
     Changed |= setDoesNotCapture(F, 0);
     Changed |= setOnlyReadsMemory(F, 0);
+    Changed |=
+        setOnlyAccessesInaccessibleOrArgOrErrnoMem(F, MR::ModRef, MR::Ref);
----------------
nikic wrote:

Given the existence of `environ`, we certainly can't model the environment as inaccessible memory.

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


More information about the llvm-commits mailing list