• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s
2
3; Function Attrs: norecurse nounwind readnone uwtable
4define i32 @bar(i32 %v) local_unnamed_addr #0 {
5entry:
6  %mul = shl nsw i32 %v, 1
7  ret i32 %mul
8}
9
10; Function Attrs: norecurse nounwind readonly uwtable
11define i32 @foo(i8* nocapture readonly %p) #1 {
12entry:
13  %targets = alloca [256 x i8*], align 16
14  %arrayidx1 = getelementptr inbounds [256 x i8*], [256 x i8*]* %targets, i64 0, i64 93
15  store i8* blockaddress(@foo, %if.end), i8** %arrayidx1, align 8
16  br label %for.cond2
17
18for.cond2:                                        ; preds = %if.end, %for.cond2, %entry
19; CHECK: for.cond2:                                        ; preds = %.split1
20  %p.addr.0 = phi i8* [ %p, %entry ], [ %incdec.ptr5, %if.end ], [ %incdec.ptr, %for.cond2 ]
21  %incdec.ptr = getelementptr inbounds i8, i8* %p.addr.0, i64 1
22  %0 = load i8, i8* %p.addr.0, align 1
23  %cond = icmp eq i8 %0, 93
24  br i1 %cond, label %if.end.preheader, label %for.cond2
25
26if.end.preheader:                                 ; preds = %for.cond2
27  br label %if.end
28
29if.end:                                           ; preds = %if.end.preheader, %if.end
30; CHECK: if.end:                                           ; preds = %.split1
31  %p.addr.1 = phi i8* [ %incdec.ptr5, %if.end ], [ %incdec.ptr, %if.end.preheader ]
32  %incdec.ptr5 = getelementptr inbounds i8, i8* %p.addr.1, i64 1
33  %1 = load i8, i8* %p.addr.1, align 1
34  %idxprom6 = zext i8 %1 to i64
35  %arrayidx7 = getelementptr inbounds [256 x i8*], [256 x i8*]* %targets, i64 0, i64 %idxprom6
36  %2 = load i8*, i8** %arrayidx7, align 8
37  indirectbr i8* %2, [label %for.cond2, label %if.end]
38; CHECK: indirectbr i8* %2, [label %for.cond2, label %if.end]
39}
40
41;; If an indirectbr critical edge cannot be split, ignore it.
42;; The edge will not be profiled.
43; CHECK-LABEL: @cannot_split(
44; CHECK-NEXT:  entry:
45; CHECK-NEXT:    call void @llvm.instrprof.increment
46; CHECK-NOT:     call void @llvm.instrprof.increment
47define i32 @cannot_split(i8* nocapture readonly %p) {
48entry:
49  %targets = alloca <2 x i8*>, align 16
50  store <2 x i8*> <i8* blockaddress(@cannot_split, %indirect), i8* blockaddress(@cannot_split, %end)>, <2 x i8*>* %targets, align 16
51  %arrayidx2 = getelementptr inbounds i8, i8* %p, i64 1
52  %0 = load i8, i8* %arrayidx2
53  %idxprom = sext i8 %0 to i64
54  %arrayidx3 = getelementptr inbounds <2 x i8*>, <2 x i8*>* %targets, i64 0, i64 %idxprom
55  %1 = load i8*, i8** %arrayidx3, align 8
56  br label %indirect
57
58indirect:                                         ; preds = %entry, %indirect
59  indirectbr i8* %1, [label %indirect, label %end]
60
61end:                                              ; preds = %indirect
62  ret i32 0
63}
64