|
1 | 1 | ; RUN: llc < %s -mattr=+reference-types -stop-after=wasm-ref-type-mem2local | FileCheck %s
|
| 2 | +; RUN: llc < %s -stop-after=wasm-ref-type-mem2local | FileCheck %s --check-prefix=ATTR |
2 | 3 |
|
3 | 4 | target triple = "wasm32-unknown-unknown"
|
4 | 5 |
|
@@ -51,7 +52,40 @@ entry:
|
51 | 52 | %i32.loaded = load i32, ptr %alloc.i32
|
52 | 53 | call void @take_i32(i32 %i32.loaded)
|
53 | 54 | ; CHECK: %alloc.i32 = alloca i32, align 4{{$}}
|
54 |
| - ; CHECK-NOT: addrspace(1) |
| 55 | + ; CHECK-NOT: alloca i32 {{.*}} addrspace(1) |
55 | 56 |
|
56 | 57 | ret void
|
57 | 58 | }
|
| 59 | + |
| 60 | +; The same function as test_ref_type_mem2local, but here +reference-types is |
| 61 | +; given in the function attribute. |
| 62 | +; Reference type allocas should be moved to addrspace(1) |
| 63 | +; ATTR-LABEL: @test_ref_type_mem2local_func_attr |
| 64 | +define void @test_ref_type_mem2local_func_attr() #0 { |
| 65 | +entry: |
| 66 | + %alloc.externref = alloca %externref, align 1 |
| 67 | + %eref = call %externref @get_externref() |
| 68 | + store %externref %eref, ptr %alloc.externref, align 1 |
| 69 | + %eref.loaded = load %externref, ptr %alloc.externref, align 1 |
| 70 | + call void @take_externref(%externref %eref.loaded) |
| 71 | + ; ATTR: %alloc.externref.var = alloca ptr addrspace(10), align 1, addrspace(1) |
| 72 | + ; ATTR-NEXT: %eref = call ptr addrspace(10) @get_externref() |
| 73 | + ; ATTR-NEXT: store ptr addrspace(10) %eref, ptr addrspace(1) %alloc.externref.var, align 1 |
| 74 | + ; ATTR-NEXT: %eref.loaded = load ptr addrspace(10), ptr addrspace(1) %alloc.externref.var, align 1 |
| 75 | + ; ATTR-NEXT: call void @take_externref(ptr addrspace(10) %eref.loaded) |
| 76 | + |
| 77 | + %alloc.funcref = alloca %funcref, align 1 |
| 78 | + %fref = call %funcref @get_funcref() |
| 79 | + store %funcref %fref, ptr %alloc.funcref, align 1 |
| 80 | + %fref.loaded = load %funcref, ptr %alloc.funcref, align 1 |
| 81 | + call void @take_funcref(%funcref %fref.loaded) |
| 82 | + ; ATTR-NEXT: %alloc.funcref.var = alloca ptr addrspace(20), align 1, addrspace(1) |
| 83 | + ; ATTR-NEXT: %fref = call ptr addrspace(20) @get_funcref() |
| 84 | + ; ATTR-NEXT: store ptr addrspace(20) %fref, ptr addrspace(1) %alloc.funcref.var, align 1 |
| 85 | + ; ATTR-NEXT: %fref.loaded = load ptr addrspace(20), ptr addrspace(1) %alloc.funcref.var, align 1 |
| 86 | + ; ATTR-NEXT: call void @take_funcref(ptr addrspace(20) %fref.loaded) |
| 87 | + |
| 88 | + ret void |
| 89 | +} |
| 90 | + |
| 91 | +attributes #0 = { "target-features"="+reference-types" } |
0 commit comments