1; Do setup work for all below tests: generate bitcode and combined index
2; RUN: opt -module-summary %s -o %t.bc
3; RUN: opt -module-summary %p/Inputs/thinlto_indirect_call_promotion.ll -o %t2.bc
4; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
5
6; RUN: opt -function-import -summary-file %t3.thinlto.bc %t.bc -o %t4.bc -print-imports 2>&1 | FileCheck %s --check-prefix=IMPORTS
7; IMPORTS-DAG: Import a
8; IMPORTS-DAG: Import c
9
10; RUN: opt %t4.bc -icp-lto -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
11; RUN: opt %t4.bc -icp-lto -pgo-icall-prom -S -pass-remarks=pgo-icall-prom 2>&1 | FileCheck %s --check-prefix=PASS-REMARK
12; PASS-REMARK: Promote indirect call to a with count 1 out of 1
13; PASS-REMARK: Promote indirect call to c.llvm.0 with count 1 out of 1
14
15target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
16target triple = "x86_64-unknown-linux-gnu"
17
18@foo = external local_unnamed_addr global void ()*, align 8
19@bar = external local_unnamed_addr global void ()*, align 8
20
21define i32 @main() local_unnamed_addr {
22entry:
23  %0 = load void ()*, void ()** @foo, align 8
24; ICALL-PROM:   br i1 %{{[0-9]+}}, label %if.true.direct_targ, label %if.false.orig_indirect, !prof [[BRANCH_WEIGHT:![0-9]+]]
25  tail call void %0(), !prof !1
26  %1 = load void ()*, void ()** @bar, align 8
27; ICALL-PROM:   br i1 %{{[0-9]+}}, label %if.true.direct_targ1, label %if.false.orig_indirect2, !prof [[BRANCH_WEIGHT:![0-9]+]]
28  tail call void %1(), !prof !2
29  ret i32 0
30}
31
32!1 = !{!"VP", i32 0, i64 1, i64 -6289574019528802036, i64 1}
33!2 = !{!"VP", i32 0, i64 1, i64 591260329866125152, i64 1}
34
35; Should not have a VP annotation on new indirect call (check before and after
36; branch_weights annotation).
37; ICALL-PROM-NOT: !"VP"
38; ICALL-PROM: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 0}
39; ICALL-PROM-NOT: !"VP"
40