1; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s -check-prefix=MFS-DEFAULTS 2; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions -mfs-psi-cutoff=0 -mfs-count-threshold=2000 | FileCheck %s --dump-input=always -check-prefix=MFS-OPTS1 3; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions -mfs-psi-cutoff=950000 | FileCheck %s -check-prefix=MFS-OPTS2 4 5define void @foo1(i1 zeroext %0) nounwind !prof !14 !section_prefix !15 { 6;; Check that cold block is moved to .text.split. 7; MFS-DEFAULTS-LABEL: foo1 8; MFS-DEFAULTS: .section .text.split.foo1 9; MFS-DEFAULTS-NEXT: foo1.cold: 10; MFS-DEFAULTS-NOT: callq bar 11; MFS-DEFAULTS-NEXT: callq baz 12 br i1 %0, label %2, label %4, !prof !17 13 142: ; preds = %1 15 %3 = call i32 @bar() 16 br label %6 17 184: ; preds = %1 19 %5 = call i32 @baz() 20 br label %6 21 226: ; preds = %4, %2 23 %7 = tail call i32 @qux() 24 ret void 25} 26 27define void @foo2(i1 zeroext %0) nounwind !prof !23 !section_prefix !16 { 28;; Check that function marked unlikely is not split. 29; MFS-DEFAULTS-LABEL: foo2 30; MFS-DEFAULTS-NOT: foo2.cold: 31 br i1 %0, label %2, label %4, !prof !17 32 332: ; preds = %1 34 %3 = call i32 @bar() 35 br label %6 36 374: ; preds = %1 38 %5 = call i32 @baz() 39 br label %6 40 416: ; preds = %4, %2 42 %7 = tail call i32 @qux() 43 ret void 44} 45 46define void @foo3(i1 zeroext %0) nounwind !section_prefix !15 { 47;; Check that function without profile data is not split. 48; MFS-DEFAULTS-LABEL: foo3 49; MFS-DEFAULTS-NOT: foo3.cold: 50 br i1 %0, label %2, label %4 51 522: ; preds = %1 53 %3 = call i32 @bar() 54 br label %6 55 564: ; preds = %1 57 %5 = call i32 @baz() 58 br label %6 59 606: ; preds = %4, %2 61 %7 = tail call i32 @qux() 62 ret void 63} 64 65define void @foo4(i1 zeroext %0, i1 zeroext %1) nounwind !prof !20 { 66;; Check that count threshold works. 67; MFS-OPTS1-LABEL: foo4 68; MFS-OPTS1: .section .text.split.foo4 69; MFS-OPTS1-NEXT: foo4.cold: 70; MFS-OPTS1-NOT: callq bar 71; MFS-OPTS1-NOT: callq baz 72; MFS-OPTS1-NEXT: callq bam 73 br i1 %0, label %3, label %7, !prof !18 74 753: 76 %4 = call i32 @bar() 77 br label %7 78 795: 80 %6 = call i32 @baz() 81 br label %7 82 837: 84 br i1 %1, label %8, label %10, !prof !19 85 868: 87 %9 = call i32 @bam() 88 br label %12 89 9010: 91 %11 = call i32 @baz() 92 br label %12 93 9412: 95 %13 = tail call i32 @qux() 96 ret void 97} 98 99define void @foo5(i1 zeroext %0, i1 zeroext %1) nounwind !prof !20 { 100;; Check that profile summary info cutoff works. 101; MFS-OPTS2-LABEL: foo5 102; MFS-OPTS2: .section .text.split.foo5 103; MFS-OPTS2-NEXT: foo5.cold: 104; MFS-OPTS2-NOT: callq bar 105; MFS-OPTS2-NOT: callq baz 106; MFS-OPTS2-NEXT: callq bam 107 br i1 %0, label %3, label %7, !prof !21 108 1093: 110 %4 = call i32 @bar() 111 br label %7 112 1135: 114 %6 = call i32 @baz() 115 br label %7 116 1177: 118 br i1 %1, label %8, label %10, !prof !22 119 1208: 121 %9 = call i32 @bam() 122 br label %12 123 12410: 125 %11 = call i32 @baz() 126 br label %12 127 12812: 129 %13 = call i32 @qux() 130 ret void 131} 132 133define void @foo6(i1 zeroext %0) nounwind section "nosplit" !prof !14 { 134;; Check that function with section attribute is not split. 135; MFS-DEFAULTS-LABEL: foo6 136; MFS-DEFAULTS-NOT: foo6.cold: 137 br i1 %0, label %2, label %4, !prof !17 138 1392: ; preds = %1 140 %3 = call i32 @bar() 141 br label %6 142 1434: ; preds = %1 144 %5 = call i32 @baz() 145 br label %6 146 1476: ; preds = %4, %2 148 %7 = tail call i32 @qux() 149 ret void 150} 151 152define i32 @foo7(i1 zeroext %0) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !prof !14 { 153;; Check that a single cold ehpad is split out. 154; MFS-DEFAULTS-LABEL: foo7 155; MFS-DEFAULTS: .section .text.split.foo7,"ax",@progbits 156; MFS-DEFAULTS-NEXT: foo7.cold: 157; MFS-DEFAULTS: callq baz 158; MFS-DEFAULTS: callq _Unwind_Resume@PLT 159entry: 160 invoke void @_Z1fv() 161 to label %try.cont unwind label %lpad 162 163lpad: 164 %1 = landingpad { i8*, i32 } 165 cleanup 166 catch i8* bitcast (i8** @_ZTIi to i8*) 167 resume { i8*, i32 } %1 168 169try.cont: 170 br i1 %0, label %2, label %4, !prof !17 171 1722: ; preds = try.cont 173 %3 = call i32 @bar() 174 br label %6 175 1764: ; preds = %1 177 %5 = call i32 @baz() 178 br label %6 179 1806: ; preds = %4, %2 181 %7 = tail call i32 @qux() 182 ret i32 %7 183} 184 185define i32 @foo8(i1 zeroext %0) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !prof !14 { 186;; Check that all ehpads are treated as hot if one of them is hot. 187; MFS-DEFAULTS-LABEL: foo8 188; MFS-DEFAULTS: callq _Unwind_Resume@PLT 189; MFS-DEFAULTS: callq _Unwind_Resume@PLT 190; MFS-DEFAULTS: .section .text.split.foo8,"ax",@progbits 191; MFS-DEFAULTS-NEXT: foo8.cold: 192; MFS-DEFAULTS: callq baz 193entry: 194 invoke void @_Z1fv() 195 to label %try.cont unwind label %lpad1 196 197lpad1: 198 %1 = landingpad { i8*, i32 } 199 cleanup 200 catch i8* bitcast (i8** @_ZTIi to i8*) 201 resume { i8*, i32 } %1 202 203try.cont: 204 br i1 %0, label %hot, label %cold, !prof !17 205 206hot: 207 %2 = call i32 @bar() 208 invoke void @_Z1fv() 209 to label %exit unwind label %lpad2, !prof !21 210 211lpad2: 212 %3 = landingpad { i8*, i32 } 213 cleanup 214 catch i8* bitcast (i8** @_ZTIi to i8*) 215 resume { i8*, i32 } %3 216 217cold: 218 %4 = call i32 @baz() 219 br label %exit 220 221exit: 222 %5 = tail call i32 @qux() 223 ret i32 %5 224} 225 226define void @foo9(i1 zeroext %0) nounwind #0 !prof !14 { 227;; Check that function with section attribute is not split. 228; MFS-DEFAULTS-LABEL: foo9 229; MFS-DEFAULTS-NOT: foo9.cold: 230 br i1 %0, label %2, label %4, !prof !17 231 2322: ; preds = %1 233 %3 = call i32 @bar() 234 br label %6 235 2364: ; preds = %1 237 %5 = call i32 @baz() 238 br label %6 239 2406: ; preds = %4, %2 241 %7 = tail call i32 @qux() 242 ret void 243} 244 245 246declare i32 @bar() 247declare i32 @baz() 248declare i32 @bam() 249declare i32 @qux() 250declare void @_Z1fv() 251declare i32 @__gxx_personality_v0(...) 252 253@_ZTIi = external constant i8* 254 255attributes #0 = { "implicit-section-name"="nosplit" } 256 257!llvm.module.flags = !{!0} 258!0 = !{i32 1, !"ProfileSummary", !1} 259!1 = !{!2, !3, !4, !5, !6, !7, !8, !9} 260!2 = !{!"ProfileFormat", !"InstrProf"} 261!3 = !{!"TotalCount", i64 10000} 262!4 = !{!"MaxCount", i64 10} 263!5 = !{!"MaxInternalCount", i64 1} 264!6 = !{!"MaxFunctionCount", i64 1000} 265!7 = !{!"NumCounts", i64 3} 266!8 = !{!"NumFunctions", i64 5} 267!9 = !{!"DetailedSummary", !10} 268!10 = !{!11, !12, !13} 269!11 = !{i32 10000, i64 100, i32 1} 270!12 = !{i32 999900, i64 100, i32 1} 271!13 = !{i32 999999, i64 1, i32 2} 272!14 = !{!"function_entry_count", i64 7000} 273!15 = !{!"function_section_prefix", !"hot"} 274!16 = !{!"function_section_prefix", !"unlikely"} 275!17 = !{!"branch_weights", i32 7000, i32 0} 276!18 = !{!"branch_weights", i32 3000, i32 4000} 277!19 = !{!"branch_weights", i32 1000, i32 6000} 278!20 = !{!"function_entry_count", i64 10000} 279!21 = !{!"branch_weights", i32 6000, i32 4000} 280!22 = !{!"branch_weights", i32 80, i32 9920} 281!23 = !{!"function_entry_count", i64 7} 282