File: indirectbr.ll

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,388 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (76 lines) | stat: -rw-r--r-- 1,749 bytes parent folder | download | duplicates (6)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
; RUN: opt -S -sccp < %s | FileCheck %s

declare void @BB0_f()
declare void @BB1_f()

; Make sure we can eliminate what is in BB0 as we know that the indirectbr is going to BB1.
;
; CHECK-LABEL: define void @indbrtest1(
; CHECK-NOT: call void @BB0_f()
; CHECK: ret void
define void @indbrtest1() {
entry:
  indirectbr i8* blockaddress(@indbrtest1, %BB1), [label %BB0, label %BB1]
BB0:
  call void @BB0_f()
  br label %BB1
BB1:
  call void @BB1_f()
  ret void
}

; Make sure we can eliminate what is in BB0 as we know that the indirectbr is going to BB1
; by looking through the casts. The casts should be folded away when they are visited
; before the indirectbr instruction.
;
; CHECK-LABEL: define void @indbrtest2(
; CHECK-NOT: call void @BB0_f()
; CHECK: ret void
define void @indbrtest2() {
entry:
  %a = ptrtoint i8* blockaddress(@indbrtest2, %BB1) to i64
  %b = inttoptr i64 %a to i8*
  %c = bitcast i8* %b to i8*
  indirectbr i8* %b, [label %BB0, label %BB1]
BB0:
  call void @BB0_f()
  br label %BB1
BB1:
  call void @BB1_f()
  ret void
}

; Make sure we can not eliminate BB0 as we do not know the target of the indirectbr.
;
; CHECK-LABEL: define void @indbrtest3(
; CHECK: call void @BB0_f()
; CHECK: ret void
define void @indbrtest3(i8** %Q) {
entry:
  %t = load i8*, i8** %Q
  indirectbr i8* %t, [label %BB0, label %BB1]
BB0:
  call void @BB0_f()
  br label %BB1
BB1:
  call void @BB1_f()
  ret void
}

; Make sure we eliminate BB1 as we pick the first successor on undef.
;
; CHECK-LABEL: define void @indbrtest4(
; CHECK: call void @BB0_f()
; CHECK: ret void
define void @indbrtest4(i8** %Q) {
entry:
  indirectbr i8* undef, [label %BB0, label %BB1]
BB0:
  call void @BB0_f()
  br label %BB1
BB1:
  call void @BB1_f()
  ret void
}