1; RUN: opt < %s -instrprof -S -o - -do-counter-promotion=1  -skip-ret-exit-block=1 | FileCheck %s --check-prefixes=CHECK,SKIP
2; RUN: opt < %s -instrprof -S -o - -do-counter-promotion=1  -skip-ret-exit-block=0 | FileCheck %s --check-prefixes=CHECK,NOTSKIP
3
4$__llvm_profile_raw_version = comdat any
5
6@bar = dso_local local_unnamed_addr global i32 0, align 4
7@__llvm_profile_raw_version = constant i64 72057594037927941, comdat
8@__profn_foo = private constant [3 x i8] c"foo"
9
10define dso_local void @foo(i32 %n)  {
11entry:
12  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 29212902728, i32 2, i32 1)
13  br label %for.cond
14
15for.cond:
16  %i.0 = phi i32 [ 0, %entry ], [ %inc, %if.end ]
17  %cmp = icmp slt i32 %i.0, %n
18  %0 = load i32, i32* @bar, align 4
19  %tobool.not = icmp eq i32 %0, 0
20  %or.cond = and i1 %cmp, %tobool.not
21  br i1 %or.cond, label %if.end, label %cleanup
22
23if.end:
24  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 29212902728, i32 2, i32 0)
25  call void (...) @bar2()
26  %inc = add nuw nsw i32 %i.0, 1
27  br label %for.cond
28
29cleanup:
30; CHECK: cleanup:
31; SKIP-NOT:  %pgocount.promoted
32; NOTSKIP:  %pgocount.promoted
33  ret void
34}
35
36declare dso_local void @bar2(...)
37
38declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
39