[llvm] 5ba73c9 - [BuildLibCalls] Mark calloc as inaccessiblememonly
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 19 03:55:18 PST 2022
Author: Nikita Popov
Date: 2022-01-19T12:55:09+01:00
New Revision: 5ba73c924df895c95f895c2f00b7c8e76ca0d4a8
URL: https://github.com/llvm/llvm-project/commit/5ba73c924df895c95f895c2f00b7c8e76ca0d4a8
DIFF: https://github.com/llvm/llvm-project/commit/5ba73c924df895c95f895c2f00b7c8e76ca0d4a8.diff
LOG: [BuildLibCalls] Mark calloc as inaccessiblememonly
Now that DSE handles inaccessiblememonly calloc, mark it as such,
as we do with other memory allocation functions.
Added:
Modified:
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/test/Transforms/InferFunctionAttrs/annotate.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index 1459126559766..97f11ca71726f 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -575,6 +575,7 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
return Changed;
case LibFunc_calloc:
case LibFunc_vec_calloc:
+ Changed |= setOnlyAccessesInaccessibleMemory(F);
Changed |= setRetAndArgsNoUndef(F);
Changed |= setDoesNotThrow(F);
Changed |= setRetDoesNotAlias(F);
diff --git a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
index 8b88c5b30a4fb..e8ef8a569d9fc 100644
--- a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
+++ b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll
@@ -289,7 +289,7 @@ declare void @bcopy(i8*, i8*, i64)
; CHECK: declare void @bzero(i8* nocapture writeonly, i64) [[ARGMEMONLY_NOFREE_NOUNWIND_WILLRETURN]]
declare void @bzero(i8*, i64)
-; CHECK: declare noalias noundef i8* @calloc(i64 noundef, i64 noundef) [[NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
+; CHECK: declare noalias noundef i8* @calloc(i64 noundef, i64 noundef) [[INACCESSIBLEMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
declare i8* @calloc(i64, i64)
; CHECK: declare double @cbrt(double) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
@@ -492,7 +492,7 @@ declare i64 @fread(i8*, i64, i64, %opaque*)
; CHECK: declare void @free(i8* nocapture noundef) [[INACCESSIBLEMEMORARGMEMONLY_NOUNWIND_WILLRETURN:#[0-9]+]]
declare void @free(i8*)
-; CHECK: declare double @frexp(double, i32* nocapture) [[NOFREE_NOUNWIND_WILLRETURN]]
+; CHECK: declare double @frexp(double, i32* nocapture) [[NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
declare double @frexp(double, i32*)
; CHECK: declare float @frexpf(float, i32* nocapture) [[NOFREE_NOUNWIND_WILLRETURN]]
@@ -653,7 +653,7 @@ declare i32 @lstat(i8*, %opaque*)
; CHECK-LINUX: declare noundef i32 @lstat64(i8* nocapture noundef readonly, %opaque* nocapture noundef) [[NOFREE_NOUNWIND]]
declare i32 @lstat64(i8*, %opaque*)
-; CHECK: declare noalias noundef i8* @malloc(i64 noundef) [[INACCESSIBLEMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
+; CHECK: declare noalias noundef i8* @malloc(i64 noundef) [[INACCESSIBLEMEMONLY_NOFREE_NOUNWIND_WILLRETURN]]
declare i8* @malloc(i64)
; CHECK-LINUX: declare noalias noundef i8* @memalign(i64, i64) [[INACCESSIBLEMEMONLY_NOFREE_NOUNWIND_WILLRETURN]]
More information about the llvm-commits
mailing list