File: split-static-profile.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (125 lines) | stat: -rw-r--r-- 3,653 bytes parent folder | download | duplicates (8)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
; Check that the unlikely branch is outlined. Override internal branch thresholds with -hotcoldsplit-cold-probability-denom

; RUN: opt -S -passes=hotcoldsplit < %s | FileCheck %s --check-prefixes=CHECK-OUTLINE,CHECK-NOOUTLINE-BAZ
; RUN: opt -S -passes=hotcoldsplit -hotcoldsplit-cold-probability-denom=50 < %s | FileCheck --check-prefixes=CHECK-OUTLINE,CHECK-PROB %s

; int cold(const char*);
; int hot(const char*);
; void foo(int a, int b) {
;   if (a == b) [[unlikely]] { // Should be outlined.
;     cold("same");
;     cold("same");
;   } else {
;     hot("different");
;   }
; }

; void bar(int a, int b) {
;   if (a == b) [[likely]] {
;     hot("same");
;   } else { // Should be outlined.
;     cold("different");
;     cold("different");
;   }
; }

; void baz(int a, int b) {
;   if (a == b) [[likely]] {
;     hot("same");
;   } else { // Should be outlined.
;     cold("different");
;     cold("different");
;   }
; }

; All the outlined cold functions are emitted after the hot functions.
; CHECK-OUTLINE: @foo
; CHECK-OUTLINE: @bar
; CHECK-OUTLINE: @baz

; CHECK-OUTLINE: internal void @foo.cold.1() #[[ATTR0:[0-9]+]]
; CHECK-OUTLINE-NEXT: newFuncRoot
; CHECK-OUTLINE: tail call noundef i32 @cold
; CHECK-OUTLINE: tail call noundef i32 @cold

; CHECK-OUTLINE: internal void @bar.cold.1() #[[ATTR0:[0-9]+]]
; CHECK-OUTLINE-NEXT: newFuncRoot
; CHECK-OUTLINE: tail call noundef i32 @cold
; CHECK-OUTLINE: tail call noundef i32 @cold

; CHECK-NOOUTLINE-BAZ-NOT: internal void @baz.cold.1()

; CHECK-PROB: internal void @baz.cold.1() #[[ATTR0:[0-9]+]]
; CHECK-PROB-NEXT: newFuncRoot
; CHECK-PROB: tail call noundef i32 @cold
; CHECK-PROB: tail call noundef i32 @cold
; CHECK-OUTLINE: attributes #[[ATTR0]] = { cold minsize }

source_filename = "/app/example.cpp"
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"

@.str = private unnamed_addr constant [5 x i8] c"same\00", align 1
@.str.1 = private unnamed_addr constant [10 x i8] c"different\00", align 1

define dso_local void @foo(i32 noundef %a, i32 noundef %b) local_unnamed_addr {
entry:
  %cmp = icmp eq i32 %a, %b
  br i1 %cmp, label %if.then, label %if.else, !prof !1

if.then:
  %call = tail call noundef i32 @cold(ptr noundef nonnull @.str)
  %call1 = tail call noundef i32 @cold(ptr noundef nonnull @.str)
  br label %if.end

if.else:
  %call2 = tail call noundef i32 @hot(ptr noundef nonnull @.str.1)
  br label %if.end

if.end:
  ret void
}

declare noundef i32 @cold(ptr noundef) local_unnamed_addr #1

declare noundef i32 @hot(ptr noundef) local_unnamed_addr #1

define dso_local void @bar(i32 noundef %a, i32 noundef %b) local_unnamed_addr {
entry:
  %cmp = icmp eq i32 %a, %b
  br i1 %cmp, label %if.then, label %if.else, !prof !2

if.then:
  %call = tail call noundef i32 @hot(ptr noundef nonnull @.str)
  br label %if.end

if.else:
  %call1 = tail call noundef i32 @cold(ptr noundef nonnull @.str.1)
  %call2 = tail call noundef i32 @cold(ptr noundef nonnull @.str.1)
  br label %if.end

if.end:
  ret void
}

define dso_local void @baz(i32 noundef %a, i32 noundef %b) local_unnamed_addr {
entry:
  %cmp = icmp eq i32 %a, %b
  br i1 %cmp, label %if.then, label %if.else, !prof !3

if.then:
  %call = tail call noundef i32 @hot(ptr noundef nonnull @.str)
  br label %if.end

if.else:
  %call1 = tail call noundef i32 @cold(ptr noundef nonnull @.str.1)
  %call2 = tail call noundef i32 @cold(ptr noundef nonnull @.str.1)
  br label %if.end

if.end:
  ret void
}

!1 = !{!"branch_weights", i32 1, i32 2000}
!2 = !{!"branch_weights", i32 2000, i32 1}
!3 = !{!"branch_weights", i32 50, i32 1}