107 lines · plain
1; RUN: rm -rf %t && split-file %s %t2 3; RUN: llvm-profdata merge %t/default.proftext -o %t/default.profdata4; RUN: opt %t/main.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/default.profdata -S | FileCheck %s5; RUN: llvm-profdata merge %t/loop_entries.proftext -o %t/loop_entries.profdata6; RUN: opt %t/main.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/loop_entries.profdata -S | FileCheck %s7; RUN: llvm-profdata merge %t/function_entry.proftext -o %t/function_entry.profdata8; RUN: opt %t/main.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/function_entry.profdata -S | FileCheck %s9 10;--- main.ll11 12define i32 @test_simple_for_with_bypass(i32 %n) {13; CHECK: define i32 @test_simple_for_with_bypass(i32 %n)14; CHECK-SAME: !prof ![[ENTRY_COUNT:[0-9]*]]15entry:16; CHECK: entry:17 %mask = and i32 %n, 6553518 %skip = icmp eq i32 %mask, 019 br i1 %skip, label %end, label %for.entry20; CHECK: br i1 %skip, label %end, label %for.entry21; CHECK-SAME: !prof ![[BW_FOR_BYPASS:[0-9]+]]22 23for.entry:24; CHECK: for.entry:25 br label %for.cond26 27for.cond:28; CHECK: for.cond:29 %i = phi i32 [ 0, %for.entry ], [ %inc1, %for.inc ]30 %sum = phi i32 [ 1, %for.entry ], [ %inc, %for.inc ]31 %cmp = icmp slt i32 %i, %n32 br i1 %cmp, label %for.body, label %for.end, !prof !133; CHECK: br i1 %cmp, label %for.body, label %for.end34; CHECK-SAME: !prof ![[BW_FOR_COND:[0-9]+]]35 36for.body:37; CHECK: for.body:38 %inc = add nsw i32 %sum, 139 br label %for.inc40 41for.inc:42; CHECK: for.inc:43 %inc1 = add nsw i32 %i, 144 br label %for.cond45 46for.end:47; CHECK: for.end:48 br label %end49 50end:51; CHECK: end:52 %final_sum = phi i32 [ %sum, %for.end ], [ 0, %entry ]53 ret i32 %final_sum54}55 56!1 = !{!"branch_weights", i32 100000, i32 80}57 58; CHECK: ![[ENTRY_COUNT]] = !{!"function_entry_count", i64 12}59; CHECK: ![[BW_FOR_BYPASS]] = !{!"branch_weights", i32 4, i32 8}60; CHECK: ![[BW_FOR_COND]] = !{!"branch_weights", i32 123456, i32 8}61 62;--- default.proftext63 64# :ir is the flag to indicate this is IR level profile.65:ir66test_simple_for_with_bypass67# Func Hash:6853687329233729337069# Num Counters:70371# Counter Values:72123456731274875 76;--- loop_entries.proftext77 78# :ir is the flag to indicate this is IR level profile.79:ir80# Always instrument the loop entry blocks81:instrument_loop_entries82test_simple_for_with_bypass83# Func Hash:8453687329233729337085# Num Counters:86387# Counter Values:88123456891290891 92;--- function_entry.proftext93 94# :ir is the flag to indicate this is IR level profile.95:ir96# Always instrument the function entry block97:entry_first98test_simple_for_with_bypass99# Func Hash:100536873292337293370101# Num Counters:1023103# Counter Values:104121051234561068107