-
Notifications
You must be signed in to change notification settings - Fork 15.2k
RuntimeLibcalls: Add memset_pattern* calls to darwin systems #167083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/arsenm/runtime-libcalls/add-more-entries-from-targetlibraryinfo
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-llvm-selectiondag @llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesThis is one of the easier cases to comprehend in TargetLibraryInfo's Full diff: https://github.com/llvm/llvm-project/pull/167083.diff 3 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 0afe32a4ecc3c..adc0c777f0030 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -209,6 +209,16 @@ struct RuntimeLibcallsInfo {
return true;
}
+ static bool darwinHasMemsetPattern(const Triple &TT) {
+ // memset_pattern{4,8,16} is only available on iOS 3.0 and Mac OS X 10.5 and
+ // later. All versions of watchOS support it.
+ if (TT.isMacOSX())
+ return !TT.isMacOSXVersionLT(10, 5);
+ if (TT.isiOS())
+ return !TT.isOSVersionLT(3, 0);
+ return TT.isWatchOS();
+ }
+
static bool hasAEABILibcalls(const Triple &TT) {
return TT.isTargetAEABI() || TT.isTargetGNUAEABI() ||
TT.isTargetMuslAEABI() || TT.isOSFuchsia() || TT.isAndroid();
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 5f52014247060..d67aeb3757ea9 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -50,6 +50,7 @@ def isWindowsMSVCOrItaniumEnvironment : RuntimeLibcallPredicate<
def isGNUEnvironment : RuntimeLibcallPredicate<"TT.isGNUEnvironment()">;
def darwinHasSinCosStret : RuntimeLibcallPredicate<"darwinHasSinCosStret(TT)">;
def darwinHasExp10 : RuntimeLibcallPredicate<"darwinHasExp10(TT)">;
+def darwinHasMemsetPattern : RuntimeLibcallPredicate<[{darwinHasMemsetPattern(TT)}]>;
def hasExp10 : RuntimeLibcallPredicate<[{!TT.isOSDarwin()}]>;
@@ -1976,6 +1977,11 @@ defvar DarwinSinCosStret = LibcallImpls<(add __sincosf_stret, __sincos_stret,
darwinHasSinCosStret>;
defvar DarwinExp10 = LibcallImpls<(add __exp10f, __exp10), darwinHasExp10>;
+defvar DarwinMemsetPattern = LibcallImpls<(add memset_pattern4,
+ memset_pattern8,
+ memset_pattern16),
+ darwinHasMemsetPattern>;
+
defvar SecurityCheckCookieIfWinMSVC =
LibcallImpls<(add __security_check_cookie, __security_cookie),
isWindowsMSVCOrItaniumEnvironment>;
@@ -2133,7 +2139,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
AArch64LibcallImpls,
LibcallImpls<(add Int128RTLibcalls), isAArch64_ILP64>,
LibcallImpls<(add bzero), isOSDarwin>,
- DarwinExp10, DarwinSinCosStret,
+ DarwinExp10, DarwinSinCosStret, DarwinMemsetPattern,
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
DefaultLibmExp10,
DefaultStackProtector,
@@ -2603,7 +2609,7 @@ def ARMSystemLibrary
WindowARMFPIntCasts,
SecurityCheckCookieIfWinMSVC,
AEABIDivRemCalls,
- DarwinSinCosStret, DarwinExp10,
+ DarwinSinCosStret, DarwinExp10, DarwinMemsetPattern,
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
DefaultLibmExp10,
@@ -3288,7 +3294,7 @@ defvar MemChkLibcalls = [__memcpy_chk, __memset_chk, __memmove_chk];
defvar X86CommonLibcalls =
(add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides, MemChkLibcalls),
- DarwinSinCosStret, DarwinExp10,
+ DarwinSinCosStret, DarwinExp10, DarwinMemsetPattern,
X86_F128_Libcalls,
LibmHasSinCosF80, // FIXME: Depends on long double
SinCosF32F64Libcalls,
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/darwin.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/darwin.ll
new file mode 100644
index 0000000000000..bc8a24cc51bf7
--- /dev/null
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/darwin.ll
@@ -0,0 +1,22 @@
+; REQUIRES: aarch64-registered-target, arm-registered-target, x86-registered-target
+
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.5 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=i386-apple-macosx10.4 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
+
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macosx10.5 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macosx10.4 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
+
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-ios3 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64-apple-ios2 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
+
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=thumbv7-apple-ios3 < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=thumbv7-apple-ios2 < %s | FileCheck -check-prefix=NO-MEMSET-PATTERN %s
+
+ ; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm64_32-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=armv7k-apple-watchos < %s | FileCheck -check-prefix=HAS-MEMSET-PATTERN %s
+
+; HAS-MEMSET-PATTERN: declare void @memset_pattern16(...)
+; HAS-MEMSET-PATTERN: declare void @memset_pattern4(...)
+; HAS-MEMSET-PATTERN: declare void @memset_pattern8(...)
+
+; NO-MEMSET-PATTERN-NOT: memset_pattern
|
7fc2bd9 to
640cf80
Compare
06d0094 to
a25d7fe
Compare
640cf80 to
6ee0ec3
Compare
a25d7fe to
61c70b5
Compare
28d3aa9 to
abfd3b2
Compare
61c70b5 to
d787eb1
Compare
abfd3b2 to
9150bc5
Compare
d787eb1 to
5c9ed73
Compare
This is one of the easier cases to comprehend in TargetLibraryInfo's setup.
9150bc5 to
4ab6bb5
Compare
5c9ed73 to
03dc81d
Compare
fhahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks

This is one of the easier cases to comprehend in TargetLibraryInfo's
setup.