[llvm] [BuildLibCalls] Remove WriteOnly attribute for fmod function (PR #72051)

via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 12 04:48:38 PST 2023


https://github.com/lizhijin1024 created https://github.com/llvm/llvm-project/pull/72051

None

>From 4398816385ec77851579d15ba1e45eb9f76ed006 Mon Sep 17 00:00:00 2001
From: lizhijin <lizhijin3 at huawei.com>
Date: Sun, 12 Nov 2023 20:18:30 +0800
Subject: [PATCH] [BuildLibCalls] Remove WriteOnly attribute for fmod function

---
 llvm/lib/Transforms/Utils/BuildLibCalls.cpp         | 6 +++---
 llvm/test/Transforms/InferFunctionAttrs/annotate.ll | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index 594a5709ca12874..2ccc0ac3e89dd30 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -725,6 +725,9 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
   case LibFunc_frexp:
   case LibFunc_frexpf:
   case LibFunc_frexpl:
+  case LibFunc_fmod:
+  case LibFunc_fmodf:
+  case LibFunc_fmodl:
     Changed |= setDoesNotThrow(F);
     Changed |= setWillReturn(F);
     Changed |= setOnlyAccessesArgMemory(F);
@@ -1164,9 +1167,6 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
   case LibFunc_fmin:
   case LibFunc_fminf:
   case LibFunc_fminl:
-  case LibFunc_fmod:
-  case LibFunc_fmodf:
-  case LibFunc_fmodl:
   case LibFunc_isascii:
   case LibFunc_isdigit:
   case LibFunc_labs:
diff --git a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
index 456155d7e4437db..ebae17514bae06b 100644
--- a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
+++ b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
@@ -473,13 +473,13 @@ declare float @fminf(float, float)
 ; CHECK: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
 declare x86_fp80 @fminl(x86_fp80, x86_fp80)
 
-; CHECK: declare double @fmod(double, double) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
+; CHECK: declare double @fmod(double, double) [[NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
 declare double @fmod(double, double)
 
-; CHECK: declare float @fmodf(float, float) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
+; CHECK: declare float @fmodf(float, float) [[NOFREE_NOUNWIND_WILLRETURN]]
 declare float @fmodf(float, float)
 
-; CHECK: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
+; CHECK: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[NOFREE_NOUNWIND_WILLRETURN]]
 declare x86_fp80 @fmodl(x86_fp80, x86_fp80)
 
 ; CHECK: declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) [[NOFREE_NOUNWIND]]



More information about the llvm-commits mailing list