1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/test/Analysis/BlockFrequencyInfo/double_exit.ll
Duncan P. N. Exon Smith 9c5542c040 IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly.  These
are the matching assembly changes for the metadata/value split in
r223802.

  - Only use the `metadata` type when referencing metadata from a call
    intrinsic -- i.e., only when it's used as a `Value`.

  - Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
    when referencing it from call intrinsics.

So, assembly like this:

    define @foo(i32 %v) {
      call void @llvm.foo(metadata !{i32 %v}, metadata !0)
      call void @llvm.foo(metadata !{i32 7}, metadata !0)
      call void @llvm.foo(metadata !1, metadata !0)
      call void @llvm.foo(metadata !3, metadata !0)
      call void @llvm.foo(metadata !{metadata !3}, metadata !0)
      ret void, !bar !2
    }
    !0 = metadata !{metadata !2}
    !1 = metadata !{i32* @global}
    !2 = metadata !{metadata !3}
    !3 = metadata !{}

turns into this:

    define @foo(i32 %v) {
      call void @llvm.foo(metadata i32 %v, metadata !0)
      call void @llvm.foo(metadata i32 7, metadata !0)
      call void @llvm.foo(metadata i32* @global, metadata !0)
      call void @llvm.foo(metadata !3, metadata !0)
      call void @llvm.foo(metadata !{!3}, metadata !0)
      ret void, !bar !2
    }
    !0 = !{!2}
    !1 = !{i32* @global}
    !2 = !{!3}
    !3 = !{}

I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines).  I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.

This is part of PR21532.

llvm-svn: 224257
2014-12-15 19:07:53 +00:00

166 lines
4.5 KiB
LLVM

; RUN: opt < %s -analyze -block-freq | FileCheck %s
; CHECK-LABEL: Printing analysis {{.*}} for function 'double_exit':
; CHECK-NEXT: block-frequency-info: double_exit
define i32 @double_exit(i32 %N) {
; Mass = 1
; Frequency = 1
; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
entry:
br label %outer
; Mass = 1
; Backedge mass = 1/3, exit mass = 2/3
; Loop scale = 3/2
; Pseudo-edges = exit
; Pseudo-mass = 1
; Frequency = 1*3/2*1 = 3/2
; CHECK-NEXT: outer: float = 1.5,
outer:
%I.0 = phi i32 [ 0, %entry ], [ %inc6, %outer.inc ]
%Return.0 = phi i32 [ 0, %entry ], [ %Return.1, %outer.inc ]
%cmp = icmp slt i32 %I.0, %N
br i1 %cmp, label %inner, label %exit, !prof !2 ; 2:1
; Mass = 1
; Backedge mass = 3/5, exit mass = 2/5
; Loop scale = 5/2
; Pseudo-edges = outer.inc @ 1/5, exit @ 1/5
; Pseudo-mass = 2/3
; Frequency = 3/2*1*5/2*2/3 = 5/2
; CHECK-NEXT: inner: float = 2.5,
inner:
%Return.1 = phi i32 [ %Return.0, %outer ], [ %call4, %inner.inc ]
%J.0 = phi i32 [ %I.0, %outer ], [ %inc, %inner.inc ]
%cmp2 = icmp slt i32 %J.0, %N
br i1 %cmp2, label %inner.body, label %outer.inc, !prof !1 ; 4:1
; Mass = 4/5
; Frequency = 5/2*4/5 = 2
; CHECK-NEXT: inner.body: float = 2.0,
inner.body:
%call = call i32 @c2(i32 %I.0, i32 %J.0)
%tobool = icmp ne i32 %call, 0
br i1 %tobool, label %exit, label %inner.inc, !prof !0 ; 3:1
; Mass = 3/5
; Frequency = 5/2*3/5 = 3/2
; CHECK-NEXT: inner.inc: float = 1.5,
inner.inc:
%call4 = call i32 @logic2(i32 %Return.1, i32 %I.0, i32 %J.0)
%inc = add nsw i32 %J.0, 1
br label %inner
; Mass = 1/3
; Frequency = 3/2*1/3 = 1/2
; CHECK-NEXT: outer.inc: float = 0.5,
outer.inc:
%inc6 = add nsw i32 %I.0, 1
br label %outer
; Mass = 1
; Frequency = 1
; CHECK-NEXT: exit: float = 1.0, int = [[ENTRY]]
exit:
%Return.2 = phi i32 [ %Return.1, %inner.body ], [ %Return.0, %outer ]
ret i32 %Return.2
}
!0 = !{!"branch_weights", i32 1, i32 3}
!1 = !{!"branch_weights", i32 4, i32 1}
!2 = !{!"branch_weights", i32 2, i32 1}
declare i32 @c2(i32, i32)
declare i32 @logic2(i32, i32, i32)
; CHECK-LABEL: Printing analysis {{.*}} for function 'double_exit_in_loop':
; CHECK-NEXT: block-frequency-info: double_exit_in_loop
define i32 @double_exit_in_loop(i32 %N) {
; Mass = 1
; Frequency = 1
; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
entry:
br label %outer
; Mass = 1
; Backedge mass = 1/2, exit mass = 1/2
; Loop scale = 2
; Pseudo-edges = exit
; Pseudo-mass = 1
; Frequency = 1*2*1 = 2
; CHECK-NEXT: outer: float = 2.0,
outer:
%I.0 = phi i32 [ 0, %entry ], [ %inc12, %outer.inc ]
%Return.0 = phi i32 [ 0, %entry ], [ %Return.3, %outer.inc ]
%cmp = icmp slt i32 %I.0, %N
br i1 %cmp, label %middle, label %exit, !prof !3 ; 1:1
; Mass = 1
; Backedge mass = 1/3, exit mass = 2/3
; Loop scale = 3/2
; Pseudo-edges = outer.inc
; Pseudo-mass = 1/2
; Frequency = 2*1*3/2*1/2 = 3/2
; CHECK-NEXT: middle: float = 1.5,
middle:
%J.0 = phi i32 [ %I.0, %outer ], [ %inc9, %middle.inc ]
%Return.1 = phi i32 [ %Return.0, %outer ], [ %Return.2, %middle.inc ]
%cmp2 = icmp slt i32 %J.0, %N
br i1 %cmp2, label %inner, label %outer.inc, !prof !2 ; 2:1
; Mass = 1
; Backedge mass = 3/5, exit mass = 2/5
; Loop scale = 5/2
; Pseudo-edges = middle.inc @ 1/5, outer.inc @ 1/5
; Pseudo-mass = 2/3
; Frequency = 3/2*1*5/2*2/3 = 5/2
; CHECK-NEXT: inner: float = 2.5,
inner:
%Return.2 = phi i32 [ %Return.1, %middle ], [ %call7, %inner.inc ]
%K.0 = phi i32 [ %J.0, %middle ], [ %inc, %inner.inc ]
%cmp5 = icmp slt i32 %K.0, %N
br i1 %cmp5, label %inner.body, label %middle.inc, !prof !1 ; 4:1
; Mass = 4/5
; Frequency = 5/2*4/5 = 2
; CHECK-NEXT: inner.body: float = 2.0,
inner.body:
%call = call i32 @c3(i32 %I.0, i32 %J.0, i32 %K.0)
%tobool = icmp ne i32 %call, 0
br i1 %tobool, label %outer.inc, label %inner.inc, !prof !0 ; 3:1
; Mass = 3/5
; Frequency = 5/2*3/5 = 3/2
; CHECK-NEXT: inner.inc: float = 1.5,
inner.inc:
%call7 = call i32 @logic3(i32 %Return.2, i32 %I.0, i32 %J.0, i32 %K.0)
%inc = add nsw i32 %K.0, 1
br label %inner
; Mass = 1/3
; Frequency = 3/2*1/3 = 1/2
; CHECK-NEXT: middle.inc: float = 0.5,
middle.inc:
%inc9 = add nsw i32 %J.0, 1
br label %middle
; Mass = 1/2
; Frequency = 2*1/2 = 1
; CHECK-NEXT: outer.inc: float = 1.0,
outer.inc:
%Return.3 = phi i32 [ %Return.2, %inner.body ], [ %Return.1, %middle ]
%inc12 = add nsw i32 %I.0, 1
br label %outer
; Mass = 1
; Frequency = 1
; CHECK-NEXT: exit: float = 1.0, int = [[ENTRY]]
exit:
ret i32 %Return.0
}
!3 = !{!"branch_weights", i32 1, i32 1}
declare i32 @c3(i32, i32, i32)
declare i32 @logic3(i32, i32, i32, i32)