-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PGO] Test graceful handling of zero profile counts
This crashed before making fixFuncEntryCount gracefully handle zero counts.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count_sampled.proftext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:ir | ||
test_no_entry_block_counter | ||
431494656217155589 | ||
3 | ||
0 | ||
0 | ||
1 | ||
|
28 changes: 28 additions & 0 deletions
28
llvm/test/Transforms/PGOProfile/fix_entry_count_sampled.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
; RUN: llvm-profdata merge %S/Inputs/fix_entry_count_sampled.proftext -o %t.profdata | ||
; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE | ||
|
||
; Instrumentation PGO sampling makes corrupt looking counters possible. This | ||
; tests one extreme case: | ||
; Test loading zero profile counts for all instrumented blocks while the entry | ||
; block is not instrumented. Additionally include a non-zero profile count for | ||
; a select instruction, which prevents short circuiting the PGO application. | ||
|
||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
define i32 @test_no_entry_block_counter(i32 %n) { | ||
; USE: define i32 @test_no_entry_block_counter(i32 %n) | ||
; USE-SAME: !prof ![[ENTRY_COUNT:[0-9]*]] | ||
entry: | ||
%cmp = icmp slt i32 42, %n | ||
br i1 %cmp, label %tail1, label %tail2 | ||
tail1: | ||
%ret = select i1 true, i32 %n, i32 42 | ||
; USE: %ret = select i1 true, i32 %n, i32 42 | ||
; USE-SAME: !prof ![[BW_FOR_SELECT:[0-9]+]] | ||
ret i32 %ret | ||
tail2: | ||
ret i32 42 | ||
} | ||
; USE: ![[ENTRY_COUNT]] = !{!"function_entry_count", i64 0} | ||
; USE: ![[BW_FOR_SELECT]] = !{!"branch_weights", i32 1, i32 0} |