From 623cf3dfdf3e202b99e4d0529c37eb7ef2474860 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Thu, 5 Aug 2021 16:35:02 -0700 Subject: [PATCH] Mark getc_unlocked as unavailable by default Before D45736, getc_unlocked was available by default, but turned off for non-Cygwin/non-MinGW Windows. D45736 then added 9 more unlocked functions, which were unavailable by default, but it also: * left getc_unlocked enabled by default, * removed the disabling line for Windows, and * added code to enable getc_unlocked for GNU, Android, and OSX. For consistency, make getc_unlocked unavailable by default. Maybe this was the intent of D45736 anyway. Reviewed By: MaskRay, efriedma Differential Revision: https://reviews.llvm.org/D107527 --- llvm/lib/Analysis/TargetLibraryInfo.cpp | 1 + llvm/test/Transforms/InferFunctionAttrs/annotate.ll | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index 8eb1a49..cfd9aff 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -123,6 +123,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, // Set IO unlocked variants as unavailable // Set them as available per system below + TLI.setUnavailable(LibFunc_getc_unlocked); TLI.setUnavailable(LibFunc_getchar_unlocked); TLI.setUnavailable(LibFunc_putc_unlocked); TLI.setUnavailable(LibFunc_putchar_unlocked); diff --git a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll index 31656e2..80fb3ec 100644 --- a/llvm/test/Transforms/InferFunctionAttrs/annotate.ll +++ b/llvm/test/Transforms/InferFunctionAttrs/annotate.ll @@ -509,7 +509,9 @@ declare i64 @fwrite(i8*, i64, i64, %opaque*) ; CHECK: declare noundef i32 @getc(%opaque* nocapture noundef) [[NOFREE_NOUNWIND]] declare i32 @getc(%opaque*) -; CHECK: declare noundef i32 @getc_unlocked(%opaque* nocapture noundef) [[NOFREE_NOUNWIND]] +; CHECK-KNOWN: declare noundef i32 @getc_unlocked(%opaque* nocapture noundef) [[NOFREE_NOUNWIND]] +; CHECK-UNKNOWN: declare i32 @getc_unlocked(%opaque*) +; CHECK-UNKNOWN-NOT: #{{.*}} declare i32 @getc_unlocked(%opaque*) ; CHECK: declare noundef i32 @getchar() [[NOFREE_NOUNWIND]] -- 2.7.4