129 lines · plain
1; RUN: llc %s -enable-machine-outliner=never -mtriple=arm64-linux-gnu -o - | \2; RUN: FileCheck --check-prefixes=CHECK,CHECK-LINUX %s3; <rdar://problem/14199482> ARM64: Calls to bzero() replaced with calls to memset()4 5; CHECK-LABEL: fct1:6; For small size (<= 256), we do not change memset to bzero.7; CHECK-DARWIN: {{b|bl}} _memset8; CHECK-LINUX: {{b|bl}} memset9define void @fct1(ptr nocapture %ptr) !prof !14 {10entry:11 tail call void @llvm.memset.p0.i64(ptr %ptr, i8 0, i64 256, i1 false)12 ret void13}14 15declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1)16 17; CHECK-LABEL: fct2:18; When the size is bigger than 256, change into bzero.19; CHECK-DARWIN: {{b|bl}} _bzero20; CHECK-LINUX: {{b|bl}} memset21define void @fct2(ptr nocapture %ptr) !prof !14 {22entry:23 tail call void @llvm.memset.p0.i64(ptr %ptr, i8 0, i64 257, i1 false)24 ret void25}26 27; CHECK-LABEL: fct3:28; For unknown size, change to bzero.29; CHECK-DARWIN: {{b|bl}} _bzero30; CHECK-LINUX: {{b|bl}} memset31define void @fct3(ptr nocapture %ptr, i32 %unknown) !prof !14 {32entry:33 %conv = sext i32 %unknown to i6434 tail call void @llvm.memset.p0.i64(ptr %ptr, i8 0, i64 %conv, i1 false)35 ret void36}37 38; CHECK-LABEL: fct4:39; Size <= 256, no change.40; CHECK-DARWIN: {{b|bl}} _memset41; CHECK-LINUX: {{b|bl}} memset42define void @fct4(ptr %ptr) !prof !14 {43entry:44 %tmp = tail call i64 @llvm.objectsize.i64(ptr %ptr, i1 false)45 %call = tail call ptr @__memset_chk(ptr %ptr, i32 0, i64 256, i64 %tmp)46 ret void47}48 49declare ptr @__memset_chk(ptr, i32, i64, i64)50 51declare i64 @llvm.objectsize.i64(ptr, i1)52 53; CHECK-LABEL: fct5:54; Size > 256, change.55; CHECK-DARWIN: {{b|bl}} _bzero56; CHECK-LINUX: {{b|bl}} memset57define void @fct5(ptr %ptr) !prof !14 {58entry:59 %tmp = tail call i64 @llvm.objectsize.i64(ptr %ptr, i1 false)60 %call = tail call ptr @__memset_chk(ptr %ptr, i32 0, i64 257, i64 %tmp)61 ret void62}63 64; CHECK-LABEL: fct6:65; Size = unknown, change.66; CHECK-DARWIN: {{b|bl}} _bzero67; CHECK-LINUX: {{b|bl}} memset68define void @fct6(ptr %ptr, i32 %unknown) !prof !14 {69entry:70 %conv = sext i32 %unknown to i6471 %tmp = tail call i64 @llvm.objectsize.i64(ptr %ptr, i1 false)72 %call = tail call ptr @__memset_chk(ptr %ptr, i32 0, i64 %conv, i64 %tmp)73 ret void74}75 76; Next functions check that memset is not turned into bzero77; when the set constant is non-zero, whatever the given size.78 79; CHECK-LABEL: fct7:80; memset with something that is not a zero, no change.81; CHECK-DARWIN: {{b|bl}} _memset82; CHECK-LINUX: {{b|bl}} memset83define void @fct7(ptr %ptr) !prof !14 {84entry:85 %tmp = tail call i64 @llvm.objectsize.i64(ptr %ptr, i1 false)86 %call = tail call ptr @__memset_chk(ptr %ptr, i32 1, i64 256, i64 %tmp)87 ret void88}89 90; CHECK-LABEL: fct8:91; memset with something that is not a zero, no change.92; CHECK-DARWIN: {{b|bl}} _memset93; CHECK-LINUX: {{b|bl}} memset94define void @fct8(ptr %ptr) !prof !14 {95entry:96 %tmp = tail call i64 @llvm.objectsize.i64(ptr %ptr, i1 false)97 %call = tail call ptr @__memset_chk(ptr %ptr, i32 1, i64 257, i64 %tmp)98 ret void99}100 101; CHECK-LABEL: fct9:102; memset with something that is not a zero, no change.103; CHECK-DARWIN: {{b|bl}} _memset104; CHECK-LINUX: {{b|bl}} memset105define void @fct9(ptr %ptr, i32 %unknown) !prof !14 {106entry:107 %conv = sext i32 %unknown to i64108 %tmp = tail call i64 @llvm.objectsize.i64(ptr %ptr, i1 false)109 %call = tail call ptr @__memset_chk(ptr %ptr, i32 1, i64 %conv, i64 %tmp)110 ret void111}112 113!llvm.module.flags = !{!0}114!0 = !{i32 1, !"ProfileSummary", !1}115!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}116!2 = !{!"ProfileFormat", !"InstrProf"}117!3 = !{!"TotalCount", i64 10000}118!4 = !{!"MaxCount", i64 10}119!5 = !{!"MaxInternalCount", i64 1}120!6 = !{!"MaxFunctionCount", i64 1000}121!7 = !{!"NumCounts", i64 3}122!8 = !{!"NumFunctions", i64 3}123!9 = !{!"DetailedSummary", !10}124!10 = !{!11, !12, !13}125!11 = !{i32 10000, i64 100, i32 1}126!12 = !{i32 999000, i64 100, i32 1}127!13 = !{i32 999999, i64 1, i32 2}128!14 = !{!"function_entry_count", i64 0}129