xref: /llvm-project/llvm/test/Transforms/PGOProfile/suppl-profile.ll (revision d7ef0c3970c238af40f3d184f900d20fd2308d7f)
1a23f6234SWei Mi; Supplement instr profile suppl-profile.proftext with sample profile
2a23f6234SWei Mi; sample-profile.proftext.
3*d7ef0c39SRong Xu; For hot functions:
4a23f6234SWei Mi; RUN: llvm-profdata merge -instr -suppl-min-size-threshold=0 \
5*d7ef0c39SRong Xu; RUN:   -supplement-instr-with-sample=%p/Inputs/sample-profile-hot.proftext \
6a23f6234SWei Mi; RUN:   %S/Inputs/suppl-profile.proftext -o %t.profdata
7*d7ef0c39SRong Xu; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=HOT
8*d7ef0c39SRong Xu; For warm functions:
9*d7ef0c39SRong Xu; RUN: llvm-profdata merge -instr -suppl-min-size-threshold=0 \
10*d7ef0c39SRong Xu; RUN:   -supplement-instr-with-sample=%p/Inputs/sample-profile-warm.proftext \
11*d7ef0c39SRong Xu; RUN:   %S/Inputs/suppl-profile.proftext -o %t1.profdata
12*d7ef0c39SRong Xu; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t1.profdata -S | FileCheck %s --check-prefix=WARM
13a23f6234SWei Mi
14a23f6234SWei Mitarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
15a23f6234SWei Mitarget triple = "x86_64-unknown-linux-gnu"
16a23f6234SWei Mi
17*d7ef0c39SRong Xu; Check test_simple_for has proper hot/cold attribute and no profile counts.
18*d7ef0c39SRong Xu; HOT: @test_simple_for(i32 %n)
19*d7ef0c39SRong Xu; HOT-SAME: #[[ATTRIBTE:[0-9]*]]
20*d7ef0c39SRong Xu; HOT-NOT: !prof !{{.*}}
21*d7ef0c39SRong Xu; HOT-SAME: {
22*d7ef0c39SRong Xu; HOT: attributes #[[ATTRIBTE]] = { hot }
23*d7ef0c39SRong Xu; WARM: @test_simple_for(i32 %n)
24*d7ef0c39SRong Xu; WARM-NOT: #{{.*}}
25*d7ef0c39SRong Xu; WARM-NOT: !prof !{{.*}}
26*d7ef0c39SRong Xu; WARM-SAME: {
27*d7ef0c39SRong Xudefine i32 @test_simple_for(i32 %n) #0 {
28a23f6234SWei Mientry:
29a23f6234SWei Mi  br label %for.cond
30a23f6234SWei Mi
31a23f6234SWei Mifor.cond:
32a23f6234SWei Mi  %i = phi i32 [ 0, %entry ], [ %inc1, %for.inc ]
33a23f6234SWei Mi  %sum = phi i32 [ 1, %entry ], [ %inc, %for.inc ]
34a23f6234SWei Mi  %cmp = icmp slt i32 %i, %n
35a23f6234SWei Mi  br i1 %cmp, label %for.body, label %for.end
36a23f6234SWei Mi
37a23f6234SWei Mifor.body:
38a23f6234SWei Mi  %inc = add nsw i32 %sum, 1
39a23f6234SWei Mi  br label %for.inc
40a23f6234SWei Mi
41a23f6234SWei Mifor.inc:
42a23f6234SWei Mi  %inc1 = add nsw i32 %i, 1
43a23f6234SWei Mi  br label %for.cond
44a23f6234SWei Mi
45a23f6234SWei Mifor.end:
46a23f6234SWei Mi  ret i32 %sum
47a23f6234SWei Mi}
48*d7ef0c39SRong Xu
49*d7ef0c39SRong Xuattributes #0 = { cold }
50