brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · cf022dd Raw
73 lines · plain
1; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s2 3; Function Attrs: norecurse nounwind readnone uwtable4define i32 @bar(i32 %v) local_unnamed_addr #0 {5entry:6  %mul = shl nsw i32 %v, 17  ret i32 %mul8}9 10; Function Attrs: norecurse nounwind readonly uwtable11define i32 @foo(ptr nocapture readonly %p) #1 {12entry:13  %targets = alloca [256 x ptr], align 1614  %arrayidx1 = getelementptr inbounds [256 x ptr], ptr %targets, i64 0, i64 9315  store ptr blockaddress(@foo, %if.end), ptr %arrayidx1, align 816  br label %for.cond217 18for.cond2:                                        ; preds = %if.end, %for.cond2, %entry19; CHECK: for.cond2:                                        ; preds = %.split120  %p.addr.0 = phi ptr [ %p, %entry ], [ %incdec.ptr5, %if.end ], [ %incdec.ptr, %for.cond2 ]21  %incdec.ptr = getelementptr inbounds i8, ptr %p.addr.0, i64 122  %0 = load i8, ptr %p.addr.0, align 123  %cond = icmp eq i8 %0, 9324  br i1 %cond, label %if.end.preheader, label %for.cond225 26if.end.preheader:                                 ; preds = %for.cond227  br label %if.end28 29if.end:                                           ; preds = %if.end.preheader, %if.end30; CHECK: if.end:                                           ; preds = %.split131  %p.addr.1 = phi ptr [ %incdec.ptr5, %if.end ], [ %incdec.ptr, %if.end.preheader ]32  %incdec.ptr5 = getelementptr inbounds i8, ptr %p.addr.1, i64 133  %1 = load i8, ptr %p.addr.1, align 134  %idxprom6 = zext i8 %1 to i6435  %arrayidx7 = getelementptr inbounds [256 x ptr], ptr %targets, i64 0, i64 %idxprom636  %2 = load ptr, ptr %arrayidx7, align 837  indirectbr ptr %2, [label %for.cond2, label %if.end]38; CHECK: indirectbr ptr %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:    %targets = alloca <2 x ptr>, align 1646; CHECK-NEXT:    call void @llvm.instrprof.increment47; CHECK: indirect:48; CHECK-NOT:     call void @llvm.instrprof.increment49; CHECK: indirect2:50; CHECK-NEXT:    call void @llvm.instrprof.increment51define i32 @cannot_split(ptr nocapture readonly %p) {52entry:53  %targets = alloca <2 x ptr>, align 1654  store <2 x ptr> <ptr blockaddress(@cannot_split, %indirect), ptr blockaddress(@cannot_split, %end)>, ptr %targets, align 1655  %arrayidx2 = getelementptr inbounds i8, ptr %p, i64 156  %0 = load i8, ptr %arrayidx257  %idxprom = sext i8 %0 to i6458  %arrayidx3 = getelementptr inbounds <2 x ptr>, ptr %targets, i64 0, i64 %idxprom59  %1 = load ptr, ptr %arrayidx3, align 860  br label %indirect61 62indirect:                                         ; preds = %entry, %indirect63  indirectbr ptr %1, [label %indirect, label %end, label %indirect2]64 65indirect2:66  ; For this test we do not want critical edges split. Adding a 2nd `indirectbr`67  ; does the trick.68  indirectbr ptr %1, [label %indirect, label %end]69 70end:                                              ; preds = %indirect71  ret i32 072}73