Mark getc_unlocked as unavailable by default
authorRyan Prichard <rprichard@google.com>
Thu, 5 Aug 2021 23:35:02 +0000 (16:35 -0700)
committerRyan Prichard <rprichard@google.com>
Thu, 5 Aug 2021 23:35:02 +0000 (16:35 -0700)
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
llvm/test/Transforms/InferFunctionAttrs/annotate.ll

index 8eb1a49..cfd9aff 100644 (file)
@@ -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);
index 31656e2..80fb3ec 100644 (file)
@@ -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]]