[PATCH] [ARM64] Prefer generation of bzero on Darwin only
Bradley Smith
bradley.smith at arm.com
Thu May 1 06:12:54 PDT 2014
Hi t.p.northover,
This patch modifies the behavior of the ARM64 backend to only prefer generating bzero for zero memsets when the target is Darwin, since not all target libraries will have this function. This matches the behavior of x86 (almost, x86 is MacOSX >= 10.6 however for ARM64 I believe that just checking for Darwin should be sufficient), no other backends use bzero.
http://reviews.llvm.org/D3585
Files:
lib/Target/ARM64/ARM64Subtarget.cpp
test/CodeGen/ARM64/memset-to-bzero.ll
Index: lib/Target/ARM64/ARM64Subtarget.cpp
===================================================================
--- lib/Target/ARM64/ARM64Subtarget.cpp
+++ lib/Target/ARM64/ARM64Subtarget.cpp
@@ -90,8 +90,11 @@
/// memset with zero passed as the second argument. Otherwise it
/// returns null.
const char *ARM64Subtarget::getBZeroEntry() const {
- // At the moment, always prefer bzero.
- return "bzero";
+ // Prefer bzero on Darwin only.
+ if(isTargetDarwin())
+ return "bzero";
+
+ return nullptr;
}
void ARM64Subtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
Index: test/CodeGen/ARM64/memset-to-bzero.ll
===================================================================
--- test/CodeGen/ARM64/memset-to-bzero.ll
+++ test/CodeGen/ARM64/memset-to-bzero.ll
@@ -1,4 +1,7 @@
-; RUN: llc %s -march arm64 -o - | FileCheck %s
+; RUN: llc %s -mtriple=arm64-apple-darwin -o - | \
+; RUN: FileCheck --check-prefix=CHECK-DARWIN --check-prefix=CHECK %s
+; RUN: llc %s -mtriple=arm64-linux-gnu -o - | \
+; RUN: FileCheck --check-prefix=CHECK-LINUX --check-prefix=CHECK %s
; <rdar://problem/14199482> ARM64: Calls to bzero() replaced with calls to memset()
; CHECK: @fct1
@@ -14,16 +17,18 @@
; CHECK: @fct2
; When the size is bigger than 256, change into bzero.
-; CHECK: bzero
+; CHECK-DARWIN: bzero
+; CHECK-LINUX: memset
define void @fct2(i8* nocapture %ptr) {
entry:
tail call void @llvm.memset.p0i8.i64(i8* %ptr, i8 0, i64 257, i32 1, i1 false)
ret void
}
; CHECK: @fct3
; For unknown size, change to bzero.
-; CHECK: bzero
+; CHECK-DARWIN: bzero
+; CHECK-LINUX: memset
define void @fct3(i8* nocapture %ptr, i32 %unknown) {
entry:
%conv = sext i32 %unknown to i64
@@ -47,7 +52,8 @@
; CHECK: @fct5
; Size > 256, change.
-; CHECK: bzero
+; CHECK-DARWIN: bzero
+; CHECK-LINUX: memset
define void @fct5(i8* %ptr) {
entry:
%tmp = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false)
@@ -57,7 +63,8 @@
; CHECK: @fct6
; Size = unknown, change.
-; CHECK: bzero
+; CHECK-DARWIN: bzero
+; CHECK-LINUX: memset
define void @fct6(i8* %ptr, i32 %unknown) {
entry:
%conv = sext i32 %unknown to i64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3585.9012.patch
Type: text/x-patch
Size: 2151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140501/ce4c60d9/attachment.bin>
More information about the llvm-commits
mailing list