xref: /llvm-project/llvm/test/Transforms/PGOProfile/icp_vararg.ll (revision 9ff36df5a4a7d52c51e950522870bb64912688d2)
1cee313d2SEric Christopher; RUN: opt < %s -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
27b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
3cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
4cee313d2SEric Christopher
5*9ff36df5SFangrui Song@foo = common global ptr null, align 8
6cee313d2SEric Christopher
7cee313d2SEric Christopherdefine i32 @va_func(i32 %num, ...) {
8cee313d2SEric Christopherentry:
9cee313d2SEric Christopher  ret i32 0
10cee313d2SEric Christopher}
11cee313d2SEric Christopher
12cee313d2SEric Christopherdefine i32 @bar() #1 {
13cee313d2SEric Christopherentry:
14*9ff36df5SFangrui Song  %tmp = load ptr, ptr @foo, align 8
15*9ff36df5SFangrui Song; ICALL-PROM:  [[CMP:%[0-9]+]] = icmp eq ptr %tmp, @va_func
16cee313d2SEric Christopher; ICALL-PROM:  br i1 [[CMP]], label %if.true.direct_targ, label %if.false.orig_indirect, !prof [[BRANCH_WEIGHT:![0-9]+]]
17cee313d2SEric Christopher; ICALL-PROM:if.true.direct_targ:
18cee313d2SEric Christopher; ICALL-PROM:  [[DIRCALL_RET:%[0-9]+]] = call i32 (i32, ...) @va_func(i32 3, i32 12, i32 22, i32 4)
19cee313d2SEric Christopher; ICALL-PROM:  br label %if.end.icp
20cee313d2SEric Christopher  %call = call i32 (i32, ...) %tmp(i32 3, i32 12, i32 22, i32 4), !prof !1
21cee313d2SEric Christopher; ICALL-PROM:if.false.orig_indirect:
22cee313d2SEric Christopher; ICALL-PROM:  %call = call i32 (i32, ...) %tmp(i32 3, i32 12, i32 22, i32 4)
23cee313d2SEric Christopher; ICALL-PROM:  br label %if.end.icp
24cee313d2SEric Christopher  ret i32 %call
25cee313d2SEric Christopher; ICALL-PROM:if.end.icp:
26cee313d2SEric Christopher; ICALL-PROM:  [[PHI_RET:%[0-9]+]] = phi i32 [ %call, %if.false.orig_indirect ], [ [[DIRCALL_RET]], %if.true.direct_targ ]
27cee313d2SEric Christopher; ICALL-PROM:  ret i32 [[PHI_RET]]
28cee313d2SEric Christopher
29cee313d2SEric Christopher}
30cee313d2SEric Christopher
31cee313d2SEric Christopher!1 = !{!"VP", i32 0, i64 12345, i64 989055279648259519, i64 12345}
325c31b8b9SArthur Eubanks; ICALL-PROM: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 12345, i32 0}
33