File: fix_entry_count_sampled.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (42 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
; RUN: rm -rf %t && split-file %s %t

; RUN: llvm-profdata merge %t/main.proftext -o %t/main.profdata
; RUN: opt < %t/main.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/main.profdata -S | FileCheck %s

;--- main.ll

; 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) {
; CHECK: define i32 @test_no_entry_block_counter(i32 %n)
; CHECK-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
; CHECK:  %ret = select i1 true, i32 %n, i32 42
; CHECK-SAME: !prof ![[BW_FOR_SELECT:[0-9]+]]
  ret i32 %ret
tail2:
  ret i32 42
}
; CHECK: ![[ENTRY_COUNT]] = !{!"function_entry_count", i64 1}
; CHECK: ![[BW_FOR_SELECT]] = !{!"branch_weights", i32 1, i32 0}

;--- main.proftext
:ir
test_no_entry_block_counter
431494656217155589
3
0
0
1