Revert "[SimplifyLibcalls] Replace locked IO with unlocked IO"

This reverts r331002 due to sanitizer bot breakage.

llvm-svn: 331011
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index d3536bd..ff6aae8 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -62,18 +62,6 @@
                         }) &&
          "TargetLibraryInfoImpl function names must be sorted");
 
-  // Set IO unlocked variants as unavailable
-  // Set them as available per system below
-  TLI.setUnavailable(LibFunc_getchar_unlocked);
-  TLI.setUnavailable(LibFunc_putc_unlocked);
-  TLI.setUnavailable(LibFunc_putchar_unlocked);
-  TLI.setUnavailable(LibFunc_fputc_unlocked);
-  TLI.setUnavailable(LibFunc_fgetc_unlocked);
-  TLI.setUnavailable(LibFunc_fread_unlocked);
-  TLI.setUnavailable(LibFunc_fwrite_unlocked);
-  TLI.setUnavailable(LibFunc_fputs_unlocked);
-  TLI.setUnavailable(LibFunc_fgets_unlocked);
-
   bool ShouldExtI32Param = false, ShouldExtI32Return = false,
        ShouldSignExtI32Param = false;
   // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and
@@ -119,12 +107,6 @@
   // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
   // All versions of watchOS support it.
   if (T.isMacOSX()) {
-    // available IO unlocked variants on Mac OS X
-    TLI.setAvailable(LibFunc_getc_unlocked);
-    TLI.setAvailable(LibFunc_getchar_unlocked);
-    TLI.setAvailable(LibFunc_putc_unlocked);
-    TLI.setAvailable(LibFunc_putchar_unlocked);
-
     if (T.isMacOSXVersionLT(10, 5))
       TLI.setUnavailable(LibFunc_memset_pattern16);
   } else if (T.isiOS()) {
@@ -283,6 +265,7 @@
     TLI.setUnavailable(LibFunc_ftello);
     TLI.setUnavailable(LibFunc_ftrylockfile);
     TLI.setUnavailable(LibFunc_funlockfile);
+    TLI.setUnavailable(LibFunc_getc_unlocked);
     TLI.setUnavailable(LibFunc_getitimer);
     TLI.setUnavailable(LibFunc_getlogin_r);
     TLI.setUnavailable(LibFunc_getpwnam);
@@ -482,20 +465,6 @@
     TLI.setUnavailable(LibFunc_sinhl_finite);
   }
 
-  if (T.isOSLinux()) {
-    // available IO unlocked variants on Linux
-    TLI.setAvailable(LibFunc_getc_unlocked);
-    TLI.setAvailable(LibFunc_getchar_unlocked);
-    TLI.setAvailable(LibFunc_putc_unlocked);
-    TLI.setAvailable(LibFunc_putchar_unlocked);
-    TLI.setAvailable(LibFunc_fputc_unlocked);
-    TLI.setAvailable(LibFunc_fgetc_unlocked);
-    TLI.setAvailable(LibFunc_fread_unlocked);
-    TLI.setAvailable(LibFunc_fwrite_unlocked);
-    TLI.setAvailable(LibFunc_fputs_unlocked);
-    TLI.setAvailable(LibFunc_fgets_unlocked);
-  }
-
   // As currently implemented in clang, NVPTX code has no standard library to
   // speak of.  Headers provide a standard-ish library implementation, but many
   // of the signatures are wrong -- for example, many libm functions are not
@@ -836,7 +805,6 @@
   case LibFunc_feof:
   case LibFunc_fflush:
   case LibFunc_fgetc:
-  case LibFunc_fgetc_unlocked:
   case LibFunc_fileno:
   case LibFunc_flockfile:
   case LibFunc_free:
@@ -865,7 +833,6 @@
     return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
             FTy.getParamType(1)->isPointerTy());
   case LibFunc_fputc:
-  case LibFunc_fputc_unlocked:
   case LibFunc_fstat:
   case LibFunc_frexp:
   case LibFunc_frexpf:
@@ -873,22 +840,18 @@
   case LibFunc_fstatvfs:
     return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
   case LibFunc_fgets:
-  case LibFunc_fgets_unlocked:
     return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
             FTy.getParamType(2)->isPointerTy());
   case LibFunc_fread:
-  case LibFunc_fread_unlocked:
     return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
             FTy.getParamType(3)->isPointerTy());
   case LibFunc_fwrite:
-  case LibFunc_fwrite_unlocked:
     return (NumParams == 4 && FTy.getReturnType()->isIntegerTy() &&
             FTy.getParamType(0)->isPointerTy() &&
             FTy.getParamType(1)->isIntegerTy() &&
             FTy.getParamType(2)->isIntegerTy() &&
             FTy.getParamType(3)->isPointerTy());
   case LibFunc_fputs:
-  case LibFunc_fputs_unlocked:
     return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
             FTy.getParamType(1)->isPointerTy());
   case LibFunc_fscanf:
@@ -901,7 +864,6 @@
     return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
             FTy.getParamType(1)->isPointerTy());
   case LibFunc_getchar:
-  case LibFunc_getchar_unlocked:
     return (NumParams == 0 && FTy.getReturnType()->isIntegerTy());
   case LibFunc_gets:
     return (NumParams == 1 && FTy.getParamType(0) == PCharTy);
@@ -914,7 +876,6 @@
     return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
             FTy.getParamType(1)->isPointerTy());
   case LibFunc_putc:
-  case LibFunc_putc_unlocked:
     return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
   case LibFunc_pread:
   case LibFunc_pwrite:
@@ -1301,7 +1262,6 @@
   case LibFunc_isascii:
   case LibFunc_toascii:
   case LibFunc_putchar:
-  case LibFunc_putchar_unlocked:
     return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
             FTy.getReturnType() == FTy.getParamType(0));