Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PGO][PGSO] Enable size optimizations in code gen / target passes for…
… cold code. Summary: Split off of D67120. Reviewers: davidxl Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71288
- Loading branch information
1 parent
d6c445e
commit ed50e60
Showing
36 changed files
with
4,208 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
llvm/test/CodeGen/AArch64/arm64-memset-to-bzero-pgso.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
; RUN: llc %s -enable-machine-outliner=never -mtriple=arm64-linux-gnu -o - | \ | ||
; RUN: FileCheck --check-prefixes=CHECK,CHECK-LINUX %s | ||
; <rdar://problem/14199482> ARM64: Calls to bzero() replaced with calls to memset() | ||
|
||
; CHECK-LABEL: fct1: | ||
; For small size (<= 256), we do not change memset to bzero. | ||
; CHECK-DARWIN: {{b|bl}} _memset | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct1(i8* nocapture %ptr) !prof !14 { | ||
entry: | ||
tail call void @llvm.memset.p0i8.i64(i8* %ptr, i8 0, i64 256, i1 false) | ||
ret void | ||
} | ||
|
||
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) | ||
|
||
; CHECK-LABEL: fct2: | ||
; When the size is bigger than 256, change into bzero. | ||
; CHECK-DARWIN: {{b|bl}} _bzero | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct2(i8* nocapture %ptr) !prof !14 { | ||
entry: | ||
tail call void @llvm.memset.p0i8.i64(i8* %ptr, i8 0, i64 257, i1 false) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: fct3: | ||
; For unknown size, change to bzero. | ||
; CHECK-DARWIN: {{b|bl}} _bzero | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct3(i8* nocapture %ptr, i32 %unknown) !prof !14 { | ||
entry: | ||
%conv = sext i32 %unknown to i64 | ||
tail call void @llvm.memset.p0i8.i64(i8* %ptr, i8 0, i64 %conv, i1 false) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: fct4: | ||
; Size <= 256, no change. | ||
; CHECK-DARWIN: {{b|bl}} _memset | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct4(i8* %ptr) !prof !14 { | ||
entry: | ||
%tmp = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false) | ||
%call = tail call i8* @__memset_chk(i8* %ptr, i32 0, i64 256, i64 %tmp) | ||
ret void | ||
} | ||
|
||
declare i8* @__memset_chk(i8*, i32, i64, i64) | ||
|
||
declare i64 @llvm.objectsize.i64(i8*, i1) | ||
|
||
; CHECK-LABEL: fct5: | ||
; Size > 256, change. | ||
; CHECK-DARWIN: {{b|bl}} _bzero | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct5(i8* %ptr) !prof !14 { | ||
entry: | ||
%tmp = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false) | ||
%call = tail call i8* @__memset_chk(i8* %ptr, i32 0, i64 257, i64 %tmp) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: fct6: | ||
; Size = unknown, change. | ||
; CHECK-DARWIN: {{b|bl}} _bzero | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct6(i8* %ptr, i32 %unknown) !prof !14 { | ||
entry: | ||
%conv = sext i32 %unknown to i64 | ||
%tmp = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false) | ||
%call = tail call i8* @__memset_chk(i8* %ptr, i32 0, i64 %conv, i64 %tmp) | ||
ret void | ||
} | ||
|
||
; Next functions check that memset is not turned into bzero | ||
; when the set constant is non-zero, whatever the given size. | ||
|
||
; CHECK-LABEL: fct7: | ||
; memset with something that is not a zero, no change. | ||
; CHECK-DARWIN: {{b|bl}} _memset | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct7(i8* %ptr) !prof !14 { | ||
entry: | ||
%tmp = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false) | ||
%call = tail call i8* @__memset_chk(i8* %ptr, i32 1, i64 256, i64 %tmp) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: fct8: | ||
; memset with something that is not a zero, no change. | ||
; CHECK-DARWIN: {{b|bl}} _memset | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct8(i8* %ptr) !prof !14 { | ||
entry: | ||
%tmp = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false) | ||
%call = tail call i8* @__memset_chk(i8* %ptr, i32 1, i64 257, i64 %tmp) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: fct9: | ||
; memset with something that is not a zero, no change. | ||
; CHECK-DARWIN: {{b|bl}} _memset | ||
; CHECK-LINUX: {{b|bl}} memset | ||
define void @fct9(i8* %ptr, i32 %unknown) !prof !14 { | ||
entry: | ||
%conv = sext i32 %unknown to i64 | ||
%tmp = tail call i64 @llvm.objectsize.i64(i8* %ptr, i1 false) | ||
%call = tail call i8* @__memset_chk(i8* %ptr, i32 1, i64 %conv, i64 %tmp) | ||
ret void | ||
} | ||
|
||
!llvm.module.flags = !{!0} | ||
!0 = !{i32 1, !"ProfileSummary", !1} | ||
!1 = !{!2, !3, !4, !5, !6, !7, !8, !9} | ||
!2 = !{!"ProfileFormat", !"InstrProf"} | ||
!3 = !{!"TotalCount", i64 10000} | ||
!4 = !{!"MaxCount", i64 10} | ||
!5 = !{!"MaxInternalCount", i64 1} | ||
!6 = !{!"MaxFunctionCount", i64 1000} | ||
!7 = !{!"NumCounts", i64 3} | ||
!8 = !{!"NumFunctions", i64 3} | ||
!9 = !{!"DetailedSummary", !10} | ||
!10 = !{!11, !12, !13} | ||
!11 = !{i32 10000, i64 100, i32 1} | ||
!12 = !{i32 999000, i64 100, i32 1} | ||
!13 = !{i32 999999, i64 1, i32 2} | ||
!14 = !{!"function_entry_count", i64 0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.