File: bad_input.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (51 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
; RUN: opt < %s -passes='print<block-freq>' -disable-output 2>&1 | FileCheck %s

declare void @g(i32 %x)

; CHECK-LABEL: Printing analysis {{.*}} for function 'branch_weight_0':
; CHECK-NEXT: block-frequency-info: branch_weight_0
define void @branch_weight_0(i32 %a) {
; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
entry:
  br label %for.body

; Check that we get 1 and a huge frequency instead of 0,3.
; CHECK-NEXT: for.body: float = 2147483647.8,
for.body:
  %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  call void @g(i32 %i)
  %inc = add i32 %i, 1
  %cmp = icmp ugt i32 %inc, %a
  br i1 %cmp, label %for.end, label %for.body, !prof !0

; CHECK-NEXT: for.end: float = 1.0, int = [[ENTRY]]
for.end:
  ret void
}

!0 = !{!"branch_weights", i32 0, i32 3}

; CHECK-LABEL: Printing analysis {{.*}} for function 'infinite_loop'
; CHECK-NEXT: block-frequency-info: infinite_loop
define void @infinite_loop(i1 %x) {
; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
entry:
  br i1 %x, label %for.body, label %for.end, !prof !1

; Check that the infinite loop is arbitrarily scaled to max out at 4096,
; giving 2048 here.
; CHECK-NEXT: for.body: float = 2048.0,
for.body:
  %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  call void @g(i32 %i)
  %inc = add i32 %i, 1
  br label %for.body

; Check that the exit weight is half of entry, since half is lost in the
; infinite loop above.
; CHECK-NEXT: for.end: float = 0.5,
for.end:
  ret void
}

!1 = !{!"branch_weights", i32 1, i32 1}