1; RUN: opt < %s -analyze -branch-prob -enable-new-pm=0 | FileCheck %s 2; RUN: opt < %s -analyze -lazy-branch-prob -enable-new-pm=0 | FileCheck %s 3; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s 4 5define i32 @test1(i32 %i, i32* %a) { 6; CHECK: Printing analysis {{.*}} for function 'test1' 7entry: 8 br label %body 9; CHECK: edge entry -> body probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 10 11body: 12 %iv = phi i32 [ 0, %entry ], [ %next, %body ] 13 %base = phi i32 [ 0, %entry ], [ %sum, %body ] 14 %arrayidx = getelementptr inbounds i32, i32* %a, i32 %iv 15 %0 = load i32, i32* %arrayidx 16 %sum = add nsw i32 %0, %base 17 %next = add i32 %iv, 1 18 %exitcond = icmp eq i32 %next, %i 19 br i1 %exitcond, label %exit, label %body 20; CHECK: edge body -> exit probability is 0x04000000 / 0x80000000 = 3.12% 21; CHECK: edge body -> body probability is 0x7c000000 / 0x80000000 = 96.88% [HOT edge] 22 23exit: 24 ret i32 %sum 25} 26 27define i32 @test2(i32 %i, i32 %a, i32 %b) { 28; CHECK: Printing analysis {{.*}} for function 'test2' 29entry: 30 %cond = icmp ult i32 %i, 42 31 br i1 %cond, label %then, label %else, !prof !0 32; CHECK: edge entry -> then probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge] 33; CHECK: edge entry -> else probability is 0x07878788 / 0x80000000 = 5.88% 34 35then: 36 br label %exit 37; CHECK: edge then -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 38 39else: 40 br label %exit 41; CHECK: edge else -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 42 43exit: 44 %result = phi i32 [ %a, %then ], [ %b, %else ] 45 ret i32 %result 46} 47 48!0 = !{!"branch_weights", i32 64, i32 4} 49 50define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) { 51; CHECK: Printing analysis {{.*}} for function 'test3' 52entry: 53 switch i32 %i, label %case_a [ i32 1, label %case_b 54 i32 2, label %case_c 55 i32 3, label %case_d 56 i32 4, label %case_e ], !prof !1 57; CHECK: edge entry -> case_a probability is 0x06666666 / 0x80000000 = 5.00% 58; CHECK: edge entry -> case_b probability is 0x06666666 / 0x80000000 = 5.00% 59; CHECK: edge entry -> case_c probability is 0x66666666 / 0x80000000 = 80.00% 60; CHECK: edge entry -> case_d probability is 0x06666666 / 0x80000000 = 5.00% 61; CHECK: edge entry -> case_e probability is 0x06666666 / 0x80000000 = 5.00% 62 63case_a: 64 br label %exit 65; CHECK: edge case_a -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 66 67case_b: 68 br label %exit 69; CHECK: edge case_b -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 70 71case_c: 72 br label %exit 73; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 74 75case_d: 76 br label %exit 77; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 78 79case_e: 80 br label %exit 81; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 82 83exit: 84 %result = phi i32 [ %a, %case_a ], 85 [ %b, %case_b ], 86 [ %c, %case_c ], 87 [ %d, %case_d ], 88 [ %e, %case_e ] 89 ret i32 %result 90} 91 92!1 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4} 93 94define i32 @test4(i32 %x) nounwind uwtable readnone ssp { 95; CHECK: Printing analysis {{.*}} for function 'test4' 96entry: 97 %conv = sext i32 %x to i64 98 switch i64 %conv, label %return [ 99 i64 0, label %sw.bb 100 i64 1, label %sw.bb 101 i64 2, label %sw.bb 102 i64 5, label %sw.bb1 103 ], !prof !2 104; CHECK: edge entry -> return probability is 0x0a8a8a8b / 0x80000000 = 8.24% 105; CHECK: edge entry -> sw.bb probability is 0x15151515 / 0x80000000 = 16.47% 106; CHECK: edge entry -> sw.bb1 probability is 0x60606060 / 0x80000000 = 75.29% 107 108sw.bb: 109 br label %return 110 111sw.bb1: 112 br label %return 113 114return: 115 %retval.0 = phi i32 [ 5, %sw.bb1 ], [ 1, %sw.bb ], [ 0, %entry ] 116 ret i32 %retval.0 117} 118 119!2 = !{!"branch_weights", i32 7, i32 6, i32 4, i32 4, i32 64} 120 121declare void @coldfunc() cold 122 123define i32 @test5(i32 %a, i32 %b, i1 %flag) { 124; CHECK: Printing analysis {{.*}} for function 'test5' 125entry: 126 br i1 %flag, label %then, label %else 127; CHECK: edge entry -> then probability is 0x07878788 / 0x80000000 = 5.88% 128; CHECK: edge entry -> else probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge] 129 130then: 131 call void @coldfunc() 132 br label %exit 133; CHECK: edge then -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 134 135else: 136 br label %exit 137; CHECK: edge else -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 138 139exit: 140 %result = phi i32 [ %a, %then ], [ %b, %else ] 141 ret i32 %result 142} 143 144define i32 @test_cold_loop(i32 %a, i32 %b) { 145entry: 146 %cond1 = icmp eq i32 %a, 42 147 br i1 %cond1, label %header, label %exit 148 149header: 150 br label %body 151 152body: 153 %cond2 = icmp eq i32 %b, 42 154 br i1 %cond2, label %header, label %exit 155; CHECK: edge body -> header probability is 0x40000000 / 0x80000000 = 50.00% 156 157exit: 158 call void @coldfunc() 159 ret i32 %b 160} 161 162declare i32 @regular_function(i32 %i) 163 164define i32 @test_cold_call_sites_with_prof(i32 %a, i32 %b, i1 %flag, i1 %flag2) { 165; CHECK: Printing analysis {{.*}} for function 'test_cold_call_sites_with_prof' 166entry: 167 br i1 %flag, label %then, label %else 168; CHECK: edge entry -> then probability is 0x07878788 / 0x80000000 = 5.88% 169; CHECK: edge entry -> else probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge] 170 171then: 172 br i1 %flag2, label %then2, label %else2, !prof !3 173; CHECK: edge then -> then2 probability is 0x7ebb907a / 0x80000000 = 99.01% [HOT edge] 174; CHECK: edge then -> else2 probability is 0x01446f86 / 0x80000000 = 0.99% 175 176then2: 177 br label %join 178; CHECK: edge then2 -> join probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 179 180else2: 181 br label %join 182; CHECK: edge else2 -> join probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 183 184join: 185 %joinresult = phi i32 [ %a, %then2 ], [ %b, %else2 ] 186 call void @coldfunc() 187 br label %exit 188; CHECK: edge join -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 189 190else: 191 br label %exit 192; CHECK: edge else -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 193 194exit: 195 %result = phi i32 [ %joinresult, %join ], [ %b, %else ] 196 ret i32 %result 197} 198 199!3 = !{!"branch_weights", i32 100, i32 1} 200 201define i32 @test_cold_call_sites(i32* %a) { 202; Test that edges to blocks post-dominated by cold call sites 203; are marked as not expected to be taken. 204; TODO(dnovillo) The calls to regular_function should not be merged, but 205; they are currently being merged. Convert this into a code generation test 206; after that is fixed. 207 208; CHECK: Printing analysis {{.*}} for function 'test_cold_call_sites' 209; CHECK: edge entry -> then probability is 0x07878788 / 0x80000000 = 5.88% 210; CHECK: edge entry -> else probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge] 211 212entry: 213 %gep1 = getelementptr i32, i32* %a, i32 1 214 %val1 = load i32, i32* %gep1 215 %cond1 = icmp ugt i32 %val1, 1 216 br i1 %cond1, label %then, label %else 217 218then: 219 ; This function is not declared cold, but this call site is. 220 %val4 = call i32 @regular_function(i32 %val1) cold 221 br label %exit 222 223else: 224 %gep2 = getelementptr i32, i32* %a, i32 2 225 %val2 = load i32, i32* %gep2 226 %val3 = call i32 @regular_function(i32 %val2) 227 br label %exit 228 229exit: 230 %ret = phi i32 [ %val4, %then ], [ %val3, %else ] 231 ret i32 %ret 232} 233 234; CHECK-LABEL: test_invoke_code_callsite1 235define i32 @test_invoke_code_callsite1(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 236entry: 237 br i1 %c, label %if.then, label %if.end 238; Edge "entry->if.end" should have higher probability based on the cold call 239; heuristic which treat %if.then as a cold block because the normal destination 240; of the invoke instruction in %if.then is post-dominated by ColdFunc(). 241; CHECK: edge entry -> if.then probability is 0x07878788 / 0x80000000 = 5.88% 242; CHECK: edge entry -> if.end probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge] 243 244if.then: 245 invoke i32 @InvokeCall() 246 to label %invoke.cont unwind label %lpad 247; CHECK: edge if.then -> invoke.cont probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge] 248; CHECK: edge if.then -> lpad probability is 0x00000800 / 0x80000000 = 0.00% 249 250invoke.cont: 251 call void @ColdFunc() #0 252 br label %if.end 253 254lpad: 255 %ll = landingpad { i8*, i32 } 256 cleanup 257 br label %if.end 258 259if.end: 260 ret i32 0 261} 262 263; CHECK-LABEL: test_invoke_code_callsite2 264define i32 @test_invoke_code_callsite2(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 265entry: 266 br i1 %c, label %if.then, label %if.end 267 268; CHECK: edge entry -> if.then probability is 0x40000000 / 0x80000000 = 50.00% 269; CHECK: edge entry -> if.end probability is 0x40000000 / 0x80000000 = 50.00% 270 271if.then: 272 invoke i32 @InvokeCall() 273 to label %invoke.cont unwind label %lpad 274; The cold call heuristic should not kick in when the cold callsite is in EH path. 275; CHECK: edge if.then -> invoke.cont probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge] 276; CHECK: edge if.then -> lpad probability is 0x00000800 / 0x80000000 = 0.00% 277 278invoke.cont: 279 br label %if.end 280 281lpad: 282 %ll = landingpad { i8*, i32 } 283 cleanup 284 call void @ColdFunc() #0 285 br label %if.end 286 287if.end: 288 ret i32 0 289} 290 291; CHECK-LABEL: test_invoke_code_callsite3 292define i32 @test_invoke_code_callsite3(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 293entry: 294 br i1 %c, label %if.then, label %if.end 295; CHECK: edge entry -> if.then probability is 0x07878788 / 0x80000000 = 5.88% 296; CHECK: edge entry -> if.end probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge] 297 298if.then: 299 invoke i32 @InvokeCall() 300 to label %invoke.cont unwind label %lpad 301; Regardless of cold calls, edge weights from a invoke instruction should be 302; determined by the invoke heuristic. 303; CHECK: edge if.then -> invoke.cont probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge] 304; CHECK: edge if.then -> lpad probability is 0x00000800 / 0x80000000 = 0.00% 305 306invoke.cont: 307 call void @ColdFunc() #0 308 br label %if.end 309 310lpad: 311 %ll = landingpad { i8*, i32 } 312 cleanup 313 call void @ColdFunc() #0 314 br label %if.end 315 316if.end: 317 ret i32 0 318} 319 320; CHECK-LABEL: test_invoke_code_profiled 321define void @test_invoke_code_profiled(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 322entry: 323; CHECK: edge entry -> invoke.to0 probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge] 324; CHECK: edge entry -> lpad probability is 0x00000800 / 0x80000000 = 0.00% 325 invoke i32 @InvokeCall() to label %invoke.to0 unwind label %lpad 326 327invoke.to0: 328; CHECK: edge invoke.to0 -> invoke.to1 probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge] 329; CHECK: edge invoke.to0 -> lpad probability is 0x00000800 / 0x80000000 = 0.00% 330 invoke i32 @InvokeCall() to label %invoke.to1 unwind label %lpad, 331 !prof !{!"branch_weights", i32 444} 332 333invoke.to1: 334; CHECK: invoke.to1 -> invoke.to2 probability is 0x55555555 / 0x80000000 = 66.67% 335; CHECK: invoke.to1 -> lpad probability is 0x2aaaaaab / 0x80000000 = 33.33% 336 invoke i32 @InvokeCall() to label %invoke.to2 unwind label %lpad, 337 !prof !{!"branch_weights", i32 222, i32 111} 338 ret void 339 340invoke.to2: 341 ret void 342 343lpad: 344 %ll = landingpad { i8*, i32 } 345 cleanup 346 ret void 347} 348 349declare i32 @__gxx_personality_v0(...) 350declare void @ColdFunc() 351declare i32 @InvokeCall() 352 353attributes #0 = { cold } 354 355 356define i32 @zero1(i32 %i, i32 %a, i32 %b) { 357; CHECK: Printing analysis {{.*}} for function 'zero1' 358entry: 359 %cond = icmp eq i32 %i, 0 360 br i1 %cond, label %then, label %else 361; CHECK: edge entry -> then probability is 0x30000000 / 0x80000000 = 37.50% 362; CHECK: edge entry -> else probability is 0x50000000 / 0x80000000 = 62.50% 363 364then: 365 br label %exit 366 367else: 368 br label %exit 369 370exit: 371 %result = phi i32 [ %a, %then ], [ %b, %else ] 372 ret i32 %result 373} 374 375define i32 @zero2(i32 %i, i32 %a, i32 %b) { 376; CHECK: Printing analysis {{.*}} for function 'zero2' 377entry: 378 %cond = icmp ne i32 %i, -1 379 br i1 %cond, label %then, label %else 380; CHECK: edge entry -> then probability is 0x50000000 / 0x80000000 = 62.50% 381; CHECK: edge entry -> else probability is 0x30000000 / 0x80000000 = 37.50% 382 383then: 384 br label %exit 385 386else: 387 br label %exit 388 389exit: 390 %result = phi i32 [ %a, %then ], [ %b, %else ] 391 ret i32 %result 392} 393 394define i32 @zero3(i32 %i, i32 %a, i32 %b) { 395; CHECK: Printing analysis {{.*}} for function 'zero3' 396entry: 397; AND'ing with a single bit bitmask essentially leads to a bool comparison, 398; meaning we don't have probability information. 399 %and = and i32 %i, 2 400 %tobool = icmp eq i32 %and, 0 401 br i1 %tobool, label %then, label %else 402; CHECK: edge entry -> then probability is 0x40000000 / 0x80000000 = 50.00% 403; CHECK: edge entry -> else probability is 0x40000000 / 0x80000000 = 50.00% 404 405then: 406; AND'ing with other bitmask might be something else, so we still assume the 407; usual probabilities. 408 %and2 = and i32 %i, 5 409 %tobool2 = icmp eq i32 %and2, 0 410 br i1 %tobool2, label %else, label %exit 411; CHECK: edge then -> else probability is 0x30000000 / 0x80000000 = 37.50% 412; CHECK: edge then -> exit probability is 0x50000000 / 0x80000000 = 62.50% 413 414else: 415 br label %exit 416 417exit: 418 %result = phi i32 [ %a, %then ], [ %b, %else ] 419 ret i32 %result 420} 421 422define i32 @test_unreachable_with_prof_greater(i32 %a, i32 %b) { 423; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_greater' 424entry: 425 %cond = icmp eq i32 %a, 42 426 br i1 %cond, label %exit, label %unr, !prof !4 427 428; CHECK: edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge] 429; CHECK: edge entry -> unr probability is 0x00000001 / 0x80000000 = 0.00% 430 431unr: 432 unreachable 433 434exit: 435 ret i32 %b 436} 437 438!4 = !{!"branch_weights", i32 0, i32 1} 439 440define i32 @test_unreachable_with_prof_equal(i32 %a, i32 %b) { 441; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_equal' 442entry: 443 %cond = icmp eq i32 %a, 42 444 br i1 %cond, label %exit, label %unr, !prof !5 445 446; CHECK: edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge] 447; CHECK: edge entry -> unr probability is 0x00000001 / 0x80000000 = 0.00% 448 449unr: 450 unreachable 451 452exit: 453 ret i32 %b 454} 455 456!5 = !{!"branch_weights", i32 2147483647, i32 1} 457 458define i32 @test_unreachable_with_prof_zero(i32 %a, i32 %b) { 459; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_zero' 460entry: 461 %cond = icmp eq i32 %a, 42 462 br i1 %cond, label %exit, label %unr, !prof !6 463 464; CHECK: edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge] 465; CHECK: edge entry -> unr probability is 0x00000001 / 0x80000000 = 0.00% 466 467unr: 468 unreachable 469 470exit: 471 ret i32 %b 472} 473 474!6 = !{!"branch_weights", i32 0, i32 0} 475 476define i32 @test_unreachable_with_prof_less(i32 %a, i32 %b) { 477; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_less' 478entry: 479 %cond = icmp eq i32 %a, 42 480 br i1 %cond, label %exit, label %unr, !prof !7 481 482; CHECK: edge entry -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 483; CHECK: edge entry -> unr probability is 0x00000000 / 0x80000000 = 0.00% 484 485unr: 486 unreachable 487 488exit: 489 ret i32 %b 490} 491 492!7 = !{!"branch_weights", i32 1, i32 0} 493 494define i32 @test_unreachable_with_switch_prof1(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) { 495; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof1' 496entry: 497 switch i32 %i, label %case_a [ i32 1, label %case_b 498 i32 2, label %case_c 499 i32 3, label %case_d 500 i32 4, label %case_e ], !prof !8 501; Reachable probabilities keep their relation: 4/64/4/4 = 5.26% / 84.21% / 5.26% / 5.26%. 502; CHECK: edge entry -> case_a probability is 0x00000001 / 0x80000000 = 0.00% 503; CHECK: edge entry -> case_b probability is 0x06bca1af / 0x80000000 = 5.26% 504; CHECK: edge entry -> case_c probability is 0x6bca1af3 / 0x80000000 = 84.21% [HOT edge] 505; CHECK: edge entry -> case_d probability is 0x06bca1af / 0x80000000 = 5.26% 506; CHECK: edge entry -> case_e probability is 0x06bca1af / 0x80000000 = 5.26% 507 508case_a: 509 unreachable 510 511case_b: 512 br label %exit 513; CHECK: edge case_b -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 514 515case_c: 516 br label %exit 517; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 518 519case_d: 520 br label %exit 521; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 522 523case_e: 524 br label %exit 525; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 526 527exit: 528 %result = phi i32 [ %b, %case_b ], 529 [ %c, %case_c ], 530 [ %d, %case_d ], 531 [ %e, %case_e ] 532 ret i32 %result 533} 534 535!8 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4} 536 537define i32 @test_unreachable_with_switch_prof2(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) { 538; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof2' 539entry: 540 switch i32 %i, label %case_a [ i32 1, label %case_b 541 i32 2, label %case_c 542 i32 3, label %case_d 543 i32 4, label %case_e ], !prof !9 544; Reachable probabilities keep their relation: 64/4/4 = 88.89% / 5.56% / 5.56%. 545; CHECK: edge entry -> case_a probability is 0x00000001 / 0x80000000 = 0.00% 546; CHECK: edge entry -> case_b probability is 0x00000001 / 0x80000000 = 0.00% 547; CHECK: edge entry -> case_c probability is 0x71c71c71 / 0x80000000 = 88.89% [HOT edge] 548; CHECK: edge entry -> case_d probability is 0x071c71c7 / 0x80000000 = 5.56% 549; CHECK: edge entry -> case_e probability is 0x071c71c7 / 0x80000000 = 5.56% 550 551 552case_a: 553 unreachable 554 555case_b: 556 unreachable 557 558case_c: 559 br label %exit 560; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 561 562case_d: 563 br label %exit 564; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 565 566case_e: 567 br label %exit 568; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 569 570exit: 571 %result = phi i32 [ %c, %case_c ], 572 [ %d, %case_d ], 573 [ %e, %case_e ] 574 ret i32 %result 575} 576 577!9 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4} 578 579define i32 @test_unreachable_with_switch_prof3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) { 580; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof3' 581entry: 582 switch i32 %i, label %case_a [ i32 1, label %case_b 583 i32 2, label %case_c 584 i32 3, label %case_d 585 i32 4, label %case_e ], !prof !10 586; Reachable probabilities keep their relation: 64/4/4 = 88.89% / 5.56% / 5.56%. 587; CHECK: edge entry -> case_a probability is 0x00000000 / 0x80000000 = 0.00% 588; CHECK: edge entry -> case_b probability is 0x00000001 / 0x80000000 = 0.00% 589; CHECK: edge entry -> case_c probability is 0x71c71c71 / 0x80000000 = 88.89% [HOT edge] 590; CHECK: edge entry -> case_d probability is 0x071c71c7 / 0x80000000 = 5.56% 591; CHECK: edge entry -> case_e probability is 0x071c71c7 / 0x80000000 = 5.56% 592 593case_a: 594 unreachable 595 596case_b: 597 unreachable 598 599case_c: 600 br label %exit 601; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 602 603case_d: 604 br label %exit 605; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 606 607case_e: 608 br label %exit 609; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 610 611exit: 612 %result = phi i32 [ %c, %case_c ], 613 [ %d, %case_d ], 614 [ %e, %case_e ] 615 ret i32 %result 616} 617 618!10 = !{!"branch_weights", i32 0, i32 4, i32 64, i32 4, i32 4} 619 620define i32 @test_unreachable_with_switch_prof4(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) { 621; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof4' 622entry: 623 switch i32 %i, label %case_a [ i32 1, label %case_b 624 i32 2, label %case_c 625 i32 3, label %case_d 626 i32 4, label %case_e ], !prof !11 627; CHECK: edge entry -> case_a probability is 0x1999999a / 0x80000000 = 20.00% 628; CHECK: edge entry -> case_b probability is 0x1999999a / 0x80000000 = 20.00% 629; CHECK: edge entry -> case_c probability is 0x1999999a / 0x80000000 = 20.00% 630; CHECK: edge entry -> case_d probability is 0x1999999a / 0x80000000 = 20.00% 631; CHECK: edge entry -> case_e probability is 0x1999999a / 0x80000000 = 20.00% 632 633case_a: 634 unreachable 635 636case_b: 637 unreachable 638 639case_c: 640 unreachable 641 642case_d: 643 unreachable 644 645case_e: 646 unreachable 647 648} 649 650!11 = !{!"branch_weights", i32 0, i32 4, i32 64, i32 4, i32 4} 651