1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
3 ; This tests that indirectbr instructions are lowered to switches. Currently we
4 ; just re-use the IndirectBrExpand Pass; it has its own IR-level test.
5 ; So this test just ensures that the pass gets run and we can lower indirectbr
7 target triple = "wasm32"
9 @test1.targets = constant [4 x ptr] [ptr blockaddress(@test1, %bb0),
10 ptr blockaddress(@test1, %bb1),
11 ptr blockaddress(@test1, %bb2),
12 ptr blockaddress(@test1, %bb3)]
14 ; Just check the barest skeleton of the structure
23 ; CHECK: br_table ${{[^,]+}}, 1, 2, 0
31 ; CHECK: test1.targets:
37 define void @test1(ptr readonly %p, ptr %sink) #0 {
40 %i0 = load i32, ptr %p
41 %target.i0 = getelementptr [4 x ptr], ptr @test1.targets, i32 0, i32 %i0
42 %target0 = load ptr, ptr %target.i0
43 ; Only a subset of blocks are viable successors here.
44 indirectbr ptr %target0, [label %bb0, label %bb1]
48 store volatile i32 0, ptr %sink
52 store volatile i32 1, ptr %sink
56 store volatile i32 2, ptr %sink
60 store volatile i32 3, ptr %sink
64 %i.next = load i32, ptr %p
65 %target.i.next = getelementptr [4 x ptr], ptr @test1.targets, i32 0, i32 %i.next
66 %target.next = load ptr, ptr %target.i.next
67 ; A different subset of blocks are viable successors here.
68 indirectbr ptr %target.next, [label %bb1, label %bb2]