diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp --- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp @@ -860,6 +860,7 @@ Changed |= setRetAndArgsNoUndef(F); Changed |= setDoesNotThrow(F); Changed |= setDoesNotCapture(F, 0); + Changed |= setOnlyAccessesInaccessibleMemOrArgMem(F); Changed |= setOnlyReadsMemory(F, 0); break; case LibFunc_pread: diff --git a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll --- a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll +++ b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll @@ -739,8 +739,7 @@ ; CHECK: declare noundef i32 @pclose(%opaque* nocapture noundef) [[NOFREE_NOUNWIND]] declare i32 @pclose(%opaque*) - -; CHECK: declare void @perror(i8* nocapture noundef readonly) [[NOFREE_NOUNWIND]] +; CHECK: declare void @perror(i8* nocapture noundef readonly) [[INACCESSIBLEMEMORARGONLY_NOFREE_NOUNWIND:#[0-9]+]] declare void @perror(i8*) ; CHECK: declare noalias noundef %opaque* @popen(i8* nocapture noundef readonly, i8* nocapture noundef readonly) [[NOFREE_NOUNWIND]] @@ -761,7 +760,7 @@ ; CHECK: declare noundef i64 @pread(i32 noundef, i8* nocapture noundef, i64 noundef, i64 noundef) [[NOFREE]] declare i64 @pread(i32, i8*, i64, i64) -; CHECK: declare noundef i32 @printf(i8* nocapture noundef readonly, ...) [[NOFREE_NOUNWIND]] +; CHECK: declare noundef i32 @printf(i8* nocapture noundef readonly, ...) [[INACCESSIBLEMEMORARGONLY_NOFREE_NOUNWIND]] declare i32 @printf(i8*, ...) ; CHECK: declare noundef i32 @putc(i32 noundef, %opaque* nocapture noundef) [[NOFREE_NOUNWIND]] @@ -774,7 +773,7 @@ ; CHECK-UNKNOWN: declare i32 @putchar_unlocked(i32){{$}} declare i32 @putchar_unlocked(i32) -; CHECK: declare noundef i32 @puts(i8* nocapture noundef readonly) [[NOFREE_NOUNWIND]] +; CHECK: declare noundef i32 @puts(i8* nocapture noundef readonly) [[INACCESSIBLEMEMORARGONLY_NOFREE_NOUNWIND]] declare i32 @puts(i8*) ; CHECK: declare noundef i64 @pwrite(i32 noundef, i8* nocapture noundef readonly, i64 noundef, i64 noundef) [[NOFREE]] @@ -1096,6 +1095,7 @@ ; CHECK-DAG: attributes [[ARGMEMONLY_NOFREE_NOUNWIND]] = { argmemonly nofree nounwind } ; CHECK-DAG: attributes [[INACCESSIBLEMEMORARGMEMONLY_NOUNWIND_WILLRETURN_ALLOCKIND_REALLOC_ALLOCSIZE1_FAMILY_MALLOC]] = { inaccessiblemem_or_argmemonly mustprogress nounwind willreturn allockind("realloc") allocsize(1) "alloc-family"="malloc" } ; CHECK-DAG: attributes [[INACCESSIBLEMEMORARGONLY_NOFREE_NOUNWIND_WILLRETURN_FAMILY_MALLOC]] = { inaccessiblemem_or_argmemonly mustprogress nofree nounwind willreturn "alloc-family"="malloc" } +; CHECK-DAG: attributes [[INACCESSIBLEMEMORARGONLY_NOFREE_NOUNWIND]] = { inaccessiblemem_or_argmemonly nofree nounwind } ; CHECK-NVPTX-DAG: attributes [[NOFREE_NOUNWIND_READNONE]] = { nofree nosync nounwind readnone }