xref: /aosp_15_r20/external/llvm/test/CodeGen/Generic/addr-label.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc %s -o -
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker;; Reference to a label that gets deleted.
4*9880d681SAndroid Build Coastguard Workerdefine i8* @test1() nounwind {
5*9880d681SAndroid Build Coastguard Workerentry:
6*9880d681SAndroid Build Coastguard Worker	ret i8* blockaddress(@test1b, %test_label)
7*9880d681SAndroid Build Coastguard Worker}
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine i32 @test1b() nounwind {
10*9880d681SAndroid Build Coastguard Workerentry:
11*9880d681SAndroid Build Coastguard Worker	ret i32 -1
12*9880d681SAndroid Build Coastguard Workertest_label:
13*9880d681SAndroid Build Coastguard Worker	br label %ret
14*9880d681SAndroid Build Coastguard Workerret:
15*9880d681SAndroid Build Coastguard Worker	ret i32 -1
16*9880d681SAndroid Build Coastguard Worker}
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker;; Issues with referring to a label that gets RAUW'd later.
20*9880d681SAndroid Build Coastguard Workerdefine i32 @test2a() nounwind {
21*9880d681SAndroid Build Coastguard Workerentry:
22*9880d681SAndroid Build Coastguard Worker        %target = bitcast i8* blockaddress(@test2b, %test_label) to i8*
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker        call i32 @test2b(i8* %target)
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker        ret i32 0
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Workerdefine i32 @test2b(i8* %target) nounwind {
30*9880d681SAndroid Build Coastguard Workerentry:
31*9880d681SAndroid Build Coastguard Worker        indirectbr i8* %target, [label %test_label]
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Workertest_label:
34*9880d681SAndroid Build Coastguard Worker; assume some code here...
35*9880d681SAndroid Build Coastguard Worker        br label %ret
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerret:
38*9880d681SAndroid Build Coastguard Worker        ret i32 -1
39*9880d681SAndroid Build Coastguard Worker}
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Worker; Issues with a BB that gets RAUW'd to another one after references are
42*9880d681SAndroid Build Coastguard Worker; generated.
43*9880d681SAndroid Build Coastguard Workerdefine void @test3(i8** %P, i8** %Q) nounwind {
44*9880d681SAndroid Build Coastguard Workerentry:
45*9880d681SAndroid Build Coastguard Worker  store i8* blockaddress(@test3b, %test_label), i8** %P
46*9880d681SAndroid Build Coastguard Worker  store i8* blockaddress(@test3b, %ret), i8** %Q
47*9880d681SAndroid Build Coastguard Worker  ret void
48*9880d681SAndroid Build Coastguard Worker}
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard Workerdefine i32 @test3b() nounwind {
51*9880d681SAndroid Build Coastguard Workerentry:
52*9880d681SAndroid Build Coastguard Worker	br label %test_label
53*9880d681SAndroid Build Coastguard Workertest_label:
54*9880d681SAndroid Build Coastguard Worker	br label %ret
55*9880d681SAndroid Build Coastguard Workerret:
56*9880d681SAndroid Build Coastguard Worker	ret i32 -1
57*9880d681SAndroid Build Coastguard Worker}
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker; PR6673
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Workerdefine i64 @test4a() {
63*9880d681SAndroid Build Coastguard Worker	%target = bitcast i8* blockaddress(@test4b, %usermain) to i8*
64*9880d681SAndroid Build Coastguard Worker	%ret = call i64 @test4b(i8* %target)
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Worker	ret i64 %ret
67*9880d681SAndroid Build Coastguard Worker}
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Workerdefine i64 @test4b(i8* %Code) {
70*9880d681SAndroid Build Coastguard Workerentry:
71*9880d681SAndroid Build Coastguard Worker	indirectbr i8* %Code, [label %usermain]
72*9880d681SAndroid Build Coastguard Workerusermain:
73*9880d681SAndroid Build Coastguard Worker	br label %label_line_0
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Workerlabel_line_0:
76*9880d681SAndroid Build Coastguard Worker	br label %label_line_1
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Workerlabel_line_1:
79*9880d681SAndroid Build Coastguard Worker	%target = ptrtoint i8* blockaddress(@test4b, %label_line_0) to i64
80*9880d681SAndroid Build Coastguard Worker	ret i64 %target
81*9880d681SAndroid Build Coastguard Worker}
82