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