diff options
author | Teresa Johnson <tejohnson@google.com> | 2017-08-03 23:42:58 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2017-08-03 23:42:58 +0000 |
commit | dad922aba23d1204bf921c66e292b809a90a980c (patch) | |
tree | 16415d56506dc2cad4b753e3d2cfc69ca0f163b5 /test/Transforms/LoopUnroll | |
parent | 0856e7acd5f555a94c34c502f1bab83af15a12f4 (diff) |
Use profile summary to disable peeling for huge working sets
Summary:
Detect when the working set size of a profiled application is huge,
by comparing the number of counts required to reach the hot percentile
in the profile summary to a large threshold*.
When the working set size is determined to be huge, disable peeling
to avoid bloating the working set further.
*Note that the selected threshold (15K) is significantly larger than the
largest working set value in SPEC cpu2006 (which is gcc at around 11K).
Reviewers: davidxl
Subscribers: mehdi_amini, mzolotukhin, eraman, llvm-commits
Differential Revision: https://reviews.llvm.org/D36288
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopUnroll')
-rw-r--r-- | test/Transforms/LoopUnroll/peel-loop-pgo.ll | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/test/Transforms/LoopUnroll/peel-loop-pgo.ll b/test/Transforms/LoopUnroll/peel-loop-pgo.ll index ee5846c6325..361a2ca71c3 100644 --- a/test/Transforms/LoopUnroll/peel-loop-pgo.ll +++ b/test/Transforms/LoopUnroll/peel-loop-pgo.ll @@ -1,5 +1,8 @@ ; RUN: opt < %s -S -debug-only=loop-unroll -loop-unroll 2>&1 | FileCheck %s -; RUN: opt < %s -S -debug-only=loop-unroll -passes='require<opt-remark-emit>,unroll' 2>&1 | FileCheck %s +; RUN: opt < %s -S -debug-only=loop-unroll -passes='require<profile-summary>,function(require<opt-remark-emit>,unroll)' 2>&1 | FileCheck %s +; Confirm that peeling is disabled if the number of counts required to reach +; the hot percentile is above the threshold. +; RUN: opt < %s -S -profile-summary-huge-working-set-size-threshold=9 -debug-only=loop-unroll -passes='require<profile-summary>,function(require<opt-remark-emit>,unroll)' 2>&1 | FileCheck %s --check-prefix=NOPEEL ; REQUIRES: asserts ; Make sure we use the profile information correctly to peel-off 3 iterations @@ -11,19 +14,19 @@ ; CHECK-NOT: PEELING ; Confirm that no peeling occurs when we are performing full unrolling. -; RUN: opt < %s -S -debug-only=loop-unroll -passes='require<opt-remark-emit>,loop(unroll-full)' 2>&1 | FileCheck %s --check-prefix=FULLUNROLL -; FULLUNROLL-NOT: PEELING +; RUN: opt < %s -S -debug-only=loop-unroll -passes='require<opt-remark-emit>,loop(unroll-full)' 2>&1 | FileCheck %s --check-prefix=NOPEEL +; NOPEEL-NOT: PEELING ; CHECK-LABEL: @basic -; CHECK: br i1 %{{.*}}, label %[[NEXT0:.*]], label %for.cond.for.end_crit_edge, !prof !1 +; CHECK: br i1 %{{.*}}, label %[[NEXT0:.*]], label %for.cond.for.end_crit_edge, !prof !15 ; CHECK: [[NEXT0]]: -; CHECK: br i1 %{{.*}}, label %[[NEXT1:.*]], label %for.cond.for.end_crit_edge, !prof !2 +; CHECK: br i1 %{{.*}}, label %[[NEXT1:.*]], label %for.cond.for.end_crit_edge, !prof !16 ; CHECK: [[NEXT1]]: -; CHECK: br i1 %{{.*}}, label %[[NEXT2:.*]], label %for.cond.for.end_crit_edge, !prof !3 +; CHECK: br i1 %{{.*}}, label %[[NEXT2:.*]], label %for.cond.for.end_crit_edge, !prof !17 ; CHECK: [[NEXT2]]: -; CHECK: br i1 %{{.*}}, label %for.body, label %{{.*}}, !prof !4 +; CHECK: br i1 %{{.*}}, label %for.body, label %{{.*}}, !prof !18 -define void @basic(i32* %p, i32 %k) #0 !prof !0 { +define void @basic(i32* %p, i32 %k) #0 !prof !15 { entry: %cmp3 = icmp slt i32 0, %k br i1 %cmp3, label %for.body.lr.ph, label %for.end @@ -38,7 +41,7 @@ for.body: ; preds = %for.body.lr.ph, %fo store i32 %i.05, i32* %p.addr.04, align 4 %inc = add nsw i32 %i.05, 1 %cmp = icmp slt i32 %inc, %k - br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !1 + br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !16 for.cond.for.end_crit_edge: ; preds = %for.body br label %for.end @@ -54,7 +57,7 @@ for.end: ; preds = %for.cond.for.end_cr ; CHECK: for.body: ; CHECK-NOT: br ; CHECK: br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge -define void @optsize(i32* %p, i32 %k) #1 !prof !0 { +define void @optsize(i32* %p, i32 %k) #1 !prof !15 { entry: %cmp3 = icmp slt i32 0, %k br i1 %cmp3, label %for.body.lr.ph, label %for.end @@ -69,7 +72,7 @@ for.body: ; preds = %for.body.lr.ph, %fo store i32 %i.05, i32* %p.addr.04, align 4 %inc = add nsw i32 %i.05, 1 %cmp = icmp slt i32 %inc, %k - br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !1 + br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !16 for.cond.for.end_crit_edge: ; preds = %for.body br label %for.end @@ -81,11 +84,27 @@ for.end: ; preds = %for.cond.for.end_cr attributes #0 = { nounwind } attributes #1 = { nounwind optsize } -!0 = !{!"function_entry_count", i64 1} -!1 = !{!"branch_weights", i32 3001, i32 1001} - -;CHECK: !1 = !{!"branch_weights", i32 900, i32 101} -;CHECK: !2 = !{!"branch_weights", i32 540, i32 360} -;CHECK: !3 = !{!"branch_weights", i32 162, i32 378} -;CHECK: !4 = !{!"branch_weights", i32 1399, i32 162} +!llvm.module.flags = !{!1} + +!1 = !{i32 1, !"ProfileSummary", !2} +!2 = !{!3, !4, !5, !6, !7, !8, !9, !10} +!3 = !{!"ProfileFormat", !"InstrProf"} +!4 = !{!"TotalCount", i64 10} +!5 = !{!"MaxCount", i64 3} +!6 = !{!"MaxInternalCount", i64 1} +!7 = !{!"MaxFunctionCount", i64 3} +!8 = !{!"NumCounts", i64 2} +!9 = !{!"NumFunctions", i64 2} +!10 = !{!"DetailedSummary", !11} +!11 = !{!12, !13, !14} +!12 = !{i32 10000, i64 3, i32 2} +!13 = !{i32 999000, i64 1, i32 10} +!14 = !{i32 999999, i64 1, i32 10} +!15 = !{!"function_entry_count", i64 1} +!16 = !{!"branch_weights", i32 3001, i32 1001} + +;CHECK: !15 = !{!"branch_weights", i32 900, i32 101} +;CHECK: !16 = !{!"branch_weights", i32 540, i32 360} +;CHECK: !17 = !{!"branch_weights", i32 162, i32 378} +;CHECK: !18 = !{!"branch_weights", i32 1399, i32 162} |