[PATCH] D47002: [Analysis] Only use _unlocked stdio functions on linux

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 17 01:20:02 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL332581: [Analysis] Only use _unlocked stdio functions on linux (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47002?vs=147251&id=147261#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47002

Files:
  llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
  llvm/trunk/test/Transforms/InstCombine/unlocked-stdio-mingw.ll


Index: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
@@ -482,7 +482,8 @@
     TLI.setUnavailable(LibFunc_sinhl_finite);
   }
 
-  if (T.isGNUEnvironment() || (T.isAndroid() && !T.isAndroidVersionLT(28))) {
+  if ((T.isOSLinux() && T.isGNUEnvironment()) ||
+      (T.isAndroid() && !T.isAndroidVersionLT(28))) {
     // available IO unlocked variants on GNU/Linux and Android P or later
     TLI.setAvailable(LibFunc_getc_unlocked);
     TLI.setAvailable(LibFunc_getchar_unlocked);
Index: llvm/trunk/test/Transforms/InstCombine/unlocked-stdio-mingw.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/unlocked-stdio-mingw.ll
+++ llvm/trunk/test/Transforms/InstCombine/unlocked-stdio-mingw.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S -mtriple=x86_64-w64-mingw32 | FileCheck %s
+
+%struct._iobuf = type { i8*, i32, i8*, i32, i32, i32, i32, i8* }
+
+ at .str = private unnamed_addr constant [5 x i8] c"file\00", align 1
+ at .str.1 = private unnamed_addr constant [2 x i8] c"w\00", align 1
+
+; Check that this still uses the plain fputc instead of fputc_unlocked
+; for MinGW targets.
+define void @external_fputc_test() {
+; CHECK-LABEL: @external_fputc_test(
+; CHECK-NEXT:    [[CALL:%.*]] = call %struct._iobuf* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
+; CHECK-NEXT:    [[CALL1:%.*]] = call i32 @fputc(i32 99, %struct._iobuf* [[CALL]])
+; CHECK-NEXT:    ret void
+;
+  %call = call %struct._iobuf* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
+  %call1 = call i32 @fputc(i32 99, %struct._iobuf* %call)
+  ret void
+}
+
+declare %struct._iobuf* @fopen(i8*, i8*)
+declare i32 @fputc(i32, %struct._iobuf* nocapture)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47002.147261.patch
Type: text/x-patch
Size: 2134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180517/111f712a/attachment.bin>


More information about the llvm-commits mailing list