File: callbr.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (76 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (3)
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: not opt -S %s -verify 2>&1 | FileCheck %s

; CHECK: Indirect label missing from arglist.
; CHECK-NEXT: #test1
define void @test1() {
  ; The %4 in the indirect label list is not found in the blockaddresses in the
  ; arg list (bad).
  callbr void asm sideeffect "#test1", "i,i"(i8* blockaddress(@test1, %3), i8* blockaddress(@test1, %2))
  to label %1 [label %4, label %2]
1:
  ret void
2:
  ret void
3:
  ret void
4:
  ret void
}

; CHECK-NOT: Indirect label missing from arglist.
define void @test2() {
  ; %4 and %2 are both in the indirect label list and the arg list (good).
  callbr void asm sideeffect "${0:l} ${1:l}", "i,i"(i8* blockaddress(@test2, %4), i8* blockaddress(@test2, %2))
  to label %1 [label %4, label %2]
1:
  ret void
2:
  ret void
3:
  ret void
4:
  ret void
}

; CHECK-NOT: Indirect label missing from arglist.
define void @test3() {
  ; note %2 blockaddress. Such a case is possible when passing the address of
  ; a label as an input to the inline asm (both address of label and asm goto
  ; use blockaddress constants; we're testing that the indirect label list from
  ; the asm goto is in the arg list to the asm).
  callbr void asm sideeffect "${0:l} ${1:l} ${2:l}", "i,X,i"(i8* blockaddress(@test3, %4), i8* blockaddress(@test3, %2), i8* blockaddress(@test3, %3))
  to label %1 [label %3, label %4]
1:
  ret void
2:
  ret void
3:
  ret void
4:
  ret void
}

;; Ensure you cannot use the return value of a callbr in indirect targets.
; CHECK: Instruction does not dominate all uses!
; CHECK-NEXT: #test4
define i32 @test4(i1 %var) {
entry:
  %ret = callbr i32 asm sideeffect "#test4", "=r,i"(i8* blockaddress(@test4, %abnormal)) to label %normal [label %abnormal]

normal:
  ret i32 0

abnormal:
  ret i32 %ret
}

;; Ensure you cannot specify the same label as both normal and indirect targets.
; CHECK: Duplicate callbr destination!
; CHECK-NEXT: #test5
define i32 @test5() {
entry:
  %ret = callbr i32 asm sideeffect "#test5", "=r,i"(i8* blockaddress(@test5, %both)) to label %both [label %both]

both:
  ret i32 0
}