From 4d06fde7c94a2fcb6618f673b981873d2b37438f Mon Sep 17 00:00:00 2001 From: valadaptive Date: Thu, 4 Dec 2025 07:48:07 -0500 Subject: [PATCH] [InferAttrs] Mark ceil and round as memory(none) This probably should've been done in https://github.com/llvm/llvm-project/pull/124742, but it wasn't. The floor, ceil, round, and trunc family of functions all behave the same. --- llvm/lib/Transforms/Utils/BuildLibCalls.cpp | 12 ++++++------ llvm/test/Transforms/InferFunctionAttrs/annotate.ll | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp index 02b73e85d783f..213869fb993d7 100644 --- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp @@ -1227,9 +1227,6 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F, case LibFunc_atanhf: case LibFunc_atanhl: case LibFunc_atanl: - case LibFunc_ceil: - case LibFunc_ceilf: - case LibFunc_ceill: case LibFunc_cos: case LibFunc_cosh: case LibFunc_coshf: @@ -1298,9 +1295,6 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F, case LibFunc_rint: case LibFunc_rintf: case LibFunc_rintl: - case LibFunc_round: - case LibFunc_roundf: - case LibFunc_roundl: case LibFunc_scalbln: case LibFunc_scalblnf: case LibFunc_scalblnl: @@ -1338,6 +1332,9 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F, case LibFunc_copysign: case LibFunc_copysignf: case LibFunc_copysignl: + case LibFunc_ceil: + case LibFunc_ceilf: + case LibFunc_ceill: case LibFunc_fabs: case LibFunc_fabsf: case LibFunc_fabsl: @@ -1361,6 +1358,9 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F, case LibFunc_nearbyint: case LibFunc_nearbyintf: case LibFunc_nearbyintl: + case LibFunc_round: + case LibFunc_roundf: + case LibFunc_roundl: case LibFunc_toascii: case LibFunc_trunc: case LibFunc_truncf: diff --git a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll index 25a70a026a0b7..4a0a20b71dfde 100644 --- a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll +++ b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll @@ -304,13 +304,13 @@ declare float @cbrtf(float) ; CHECK: declare x86_fp80 @cbrtl(x86_fp80) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] declare x86_fp80 @cbrtl(x86_fp80) -; CHECK: declare double @ceil(double) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] +; CHECK: declare double @ceil(double) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] declare double @ceil(double) -; CHECK: declare float @ceilf(float) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] +; CHECK: declare float @ceilf(float) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] declare float @ceilf(float) -; CHECK: declare x86_fp80 @ceill(x86_fp80) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] +; CHECK: declare x86_fp80 @ceill(x86_fp80) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] declare x86_fp80 @ceill(x86_fp80) ; The second argument of int chmod(FILE*, mode_t) is a 32-bit int on most @@ -909,13 +909,13 @@ declare x86_fp80 @rintl(x86_fp80) ; CHECK: declare noundef i32 @rmdir(ptr noundef readonly captures(none)) [[NOFREE_NOUNWIND]] declare i32 @rmdir(ptr) -; CHECK: declare double @round(double) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] +; CHECK: declare double @round(double) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] declare double @round(double) -; CHECK: declare float @roundf(float) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] +; CHECK: declare float @roundf(float) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] declare float @roundf(float) -; CHECK: declare x86_fp80 @roundl(x86_fp80) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] +; CHECK: declare x86_fp80 @roundl(x86_fp80) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]] declare x86_fp80 @roundl(x86_fp80) ; CHECK: declare double @scalbln(double, i64) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]