1 ; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
3 %i32_cell = type i32 addrspace(1)*
4 %i64_cell = type i64 addrspace(1)*
5 %f32_cell = type float addrspace(1)*
6 %f64_cell = type double addrspace(1)*
8 ; We have a set of tests in which we set a local and then reload the
9 ; local. If the load immediately follows the set, the DAG combiner will
10 ; infer that the reloaded value is the same value that was set, which
11 ; isn't what we want to test. To inhibit this optimization, we include
12 ; an opaque call between the store and the load.
13 declare void @inhibit_store_to_load_forwarding()
15 define i32 @ir_local_i32(i32 %arg) {
16 ; CHECK-LABEL: ir_local_i32:
17 ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
18 %retval = alloca i32, addrspace(1)
19 ; CHECK-NEXT: .local i32
20 store i32 %arg, %i32_cell %retval
21 ; CHECK-NEXT: local.get 0
22 ; CHECK-NEXT: local.set 1
23 call void @inhibit_store_to_load_forwarding()
24 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
25 %reloaded = load i32, %i32_cell %retval
26 ; CHECK-NEXT: local.get 1
28 ; CHECK-NEXT: end_function
31 define i64 @ir_local_i64(i64 %arg) {
32 ; CHECK-LABEL: ir_local_i64:
33 ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
34 %retval = alloca i64, addrspace(1)
35 ; CHECK-NEXT: .local i64
36 store i64 %arg, %i64_cell %retval
37 ; CHECK-NEXT: local.get 0
38 ; CHECK-NEXT: local.set 1
39 call void @inhibit_store_to_load_forwarding()
40 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
41 %reloaded = load i64, %i64_cell %retval
42 ; See note in ir_local_i32.
43 ; CHECK-NEXT: local.get 1
45 ; CHECK-NEXT: end_function
48 define float @ir_local_f32(float %arg) {
49 ; CHECK-LABEL: ir_local_f32:
50 ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
51 %retval = alloca float, addrspace(1)
52 ; CHECK-NEXT: .local f32
53 store float %arg, %f32_cell %retval
54 ; CHECK-NEXT: local.get 0
55 ; CHECK-NEXT: local.set 1
56 call void @inhibit_store_to_load_forwarding()
57 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
58 %reloaded = load float, %f32_cell %retval
59 ; CHECK-NEXT: local.get 1
60 ; CHECK-NEXT: end_function
64 define double @ir_local_f64(double %arg) {
65 ; CHECK-LABEL: ir_local_f64:
66 ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
67 %retval = alloca double, addrspace(1)
68 ; CHECK-NEXT: .local f64
69 store double %arg, %f64_cell %retval
70 ; CHECK-NEXT: local.get 0
71 ; CHECK-NEXT: local.set 1
72 call void @inhibit_store_to_load_forwarding()
73 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
74 %reloaded = load double, %f64_cell %retval
75 ; CHECK-NEXT: local.get 1
76 ; CHECK-NEXT: end_function
80 define void @ir_unreferenced_local() {
81 ; CHECK-LABEL: ir_unreferenced_local:
82 ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
83 %unused = alloca i32, addrspace(1)
84 ; CHECK-NEXT: .local i32
86 ; CHECK-NEXT: end_function