Skip to content

Commit 2a92356

Browse files
committed
RuntimeLibcalls: Add macos unlocked IO functions to systems
This is another of the easier to understand conditions from TargetLibraryInfo
1 parent abfd3b2 commit 2a92356

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def isNotOSWindows : RuntimeLibcallPredicate<"!TT.isOSWindows()">;
2424
def isNotOSLinux : RuntimeLibcallPredicate<[{!TT.isOSLinux()}]>;
2525
def isNotOSMSVCRT : RuntimeLibcallPredicate<"!TT.isOSMSVCRT()">;
2626
def isPS : RuntimeLibcallPredicate<"TT.isPS()">;
27+
def isMacOSX : RuntimeLibcallPredicate<[{TT.isMacOSX()}]>;
2728
def isNotOSWindowsOrIsCygwinMinGW
2829
: RuntimeLibcallPredicate<"!TT.isOSWindows() || TT.isOSCygMing()">;
2930
def isWindowsMSVCEnvironment : RuntimeLibcallPredicate<
@@ -1982,6 +1983,10 @@ defvar DarwinMemsetPattern = LibcallImpls<(add memset_pattern4,
19821983
memset_pattern16),
19831984
darwinHasMemsetPattern>;
19841985

1986+
defvar MacOSUnlockedIO = LibcallImpls<(add
1987+
getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked),
1988+
isMacOSX>;
1989+
19851990
defvar SecurityCheckCookieIfWinMSVC =
19861991
LibcallImpls<(add __security_check_cookie, __security_cookie),
19871992
isWindowsMSVCOrItaniumEnvironment>;
@@ -2140,6 +2145,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
21402145
LibcallImpls<(add Int128RTLibcalls), isAArch64_ILP64>,
21412146
LibcallImpls<(add bzero), isOSDarwin>,
21422147
DarwinExp10, DarwinSinCosStret, DarwinMemsetPattern,
2148+
MacOSUnlockedIO,
21432149
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
21442150
DefaultLibmExp10,
21452151
DefaultStackProtector,
@@ -3294,7 +3300,7 @@ defvar MemChkLibcalls = [__memcpy_chk, __memset_chk, __memmove_chk];
32943300

32953301
defvar X86CommonLibcalls =
32963302
(add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides, MemChkLibcalls),
3297-
DarwinSinCosStret, DarwinExp10, DarwinMemsetPattern,
3303+
DarwinSinCosStret, DarwinExp10, DarwinMemsetPattern, MacOSUnlockedIO,
32983304
X86_F128_Libcalls,
32993305
LibmHasSinCosF80, // FIXME: Depends on long double
33003306
SinCosF32F64Libcalls,
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
; REQUIRES: aarch64-registered-target, arm-registered-target, x86-registered-target
22

3-
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.5 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
4-
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.4 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
3+
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.5 < %s | FileCheck -check-prefixes=HAS-MEMSET-PATTERN,MACOS %s
4+
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.4 < %s | FileCheck -check-prefixes=NO-MEMSET-PATTERN,MACOS %s
55

66
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macosx10.5 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
77
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macosx10.4 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
88

9+
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-macos10.5 < %s | FileCheck -check-prefixes=HAS-MEMSET-PATTERN,MACOS %s
910
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-ios3 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
1011
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-ios2 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
1112

@@ -15,8 +16,14 @@
1516
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64_32-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
1617
; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=armv7k-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
1718

19+
; MACOS: declare void @getc_unlocked(...)
20+
; MACOS: declare void @getchar_unlocked(...)
21+
1822
; HAS-MEMSET-PATTERN: declare void @memset_pattern16(...)
1923
; HAS-MEMSET-PATTERN: declare void @memset_pattern4(...)
2024
; HAS-MEMSET-PATTERN: declare void @memset_pattern8(...)
2125

26+
; MACOS: declare void @putc_unlocked(...)
27+
; MACOS: declare void @putchar_unlocked(...)
28+
2229
; NO-MEMSET-PATTERN-NOT: memset_pattern

0 commit comments

Comments
 (0)