xref: /llvm-project/llvm/test/Transforms/PGOProfile/indirect_call_annotation.ll (revision 9ff36df5a4a7d52c51e950522870bb64912688d2)
1cee313d2SEric Christopher; RUN: llvm-profdata merge %S/Inputs/indirect_call.proftext -o %t.profdata
2cee313d2SEric Christopher; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=VP-ANNOTATION
37b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
5cee313d2SEric Christopher
6*9ff36df5SFangrui Song@foo = common global ptr null, align 8
7cee313d2SEric Christopher
8cee313d2SEric Christopherdefine i32 @func1(i32 %x) {
9cee313d2SEric Christopherentry:
10cee313d2SEric Christopher  ret i32 %x
11cee313d2SEric Christopher}
12cee313d2SEric Christopher
13cee313d2SEric Christopherdefine i32 @func2(i32 %x) {
14cee313d2SEric Christopherentry:
15cee313d2SEric Christopher  %add = add nsw i32 %x, 1
16cee313d2SEric Christopher  ret i32 %add
17cee313d2SEric Christopher}
18cee313d2SEric Christopher
19cee313d2SEric Christopherdefine i32 @func3(i32 %x) {
20cee313d2SEric Christopherentry:
21cee313d2SEric Christopher  %add = add nsw i32 %x, 3
22cee313d2SEric Christopher  ret i32 %add
23cee313d2SEric Christopher}
24cee313d2SEric Christopher
25cee313d2SEric Christopherdefine i32 @bar(i32 %i) {
26cee313d2SEric Christopherentry:
27*9ff36df5SFangrui Song  %tmp = load ptr, ptr @foo, align 8
28cee313d2SEric Christopher  %call = call i32 %tmp(i32 %i)
29cee313d2SEric Christopher; VP-ANNOTATION: %call = call i32 %tmp(i32 %i)
30cee313d2SEric Christopher; VP-ANNOTATION-SAME: !prof ![[VP:[0-9]+]]
31cee313d2SEric Christopher; VP-ANNOTATION: ![[VP]] = !{!"VP", i32 0, i64 140, i64 -4377547752858689819, i64 80, i64 -2545542355363006406, i64 40, i64 -6929281286627296573, i64 20}
32cee313d2SEric Christopher  ret i32 %call
33cee313d2SEric Christopher}
34cee313d2SEric Christopher
35cee313d2SEric Christopher
36