File: ir-locals.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (87 lines) | stat: -rw-r--r-- 2,855 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
85
86
87
; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s

%i32_cell = type ptr addrspace(1)
%i64_cell = type ptr addrspace(1)
%f32_cell = type ptr addrspace(1)
%f64_cell = type ptr addrspace(1)

; We have a set of tests in which we set a local and then reload the
; local.  If the load immediately follows the set, the DAG combiner will
; infer that the reloaded value is the same value that was set, which
; isn't what we want to test.  To inhibit this optimization, we include
; an opaque call between the store and the load.
declare void @inhibit_store_to_load_forwarding()

define i32 @ir_local_i32(i32 %arg) {
 ; CHECK-LABEL: ir_local_i32:
 ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
 %retval = alloca i32, addrspace(1)
 ; CHECK-NEXT: .local i32
 store i32 %arg, %i32_cell %retval
 ; CHECK-NEXT: local.get 0
 ; CHECK-NEXT: local.set 1
 call void @inhibit_store_to_load_forwarding()
 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
 %reloaded = load i32, %i32_cell %retval
 ; CHECK-NEXT: local.get 1
 ret i32 %reloaded
 ; CHECK-NEXT: end_function
}

define i64 @ir_local_i64(i64 %arg) {
 ; CHECK-LABEL: ir_local_i64:
 ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
 %retval = alloca i64, addrspace(1)
 ; CHECK-NEXT: .local i64
 store i64 %arg, %i64_cell %retval
 ; CHECK-NEXT: local.get 0
 ; CHECK-NEXT: local.set 1
 call void @inhibit_store_to_load_forwarding()
 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
 %reloaded = load i64, %i64_cell %retval
 ; See note in ir_local_i32.
 ; CHECK-NEXT: local.get 1
 ret i64 %reloaded
 ; CHECK-NEXT: end_function
}

define float @ir_local_f32(float %arg) {
 ; CHECK-LABEL: ir_local_f32:
 ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
 %retval = alloca float, addrspace(1)
 ; CHECK-NEXT: .local f32
 store float %arg, %f32_cell %retval
 ; CHECK-NEXT: local.get 0
 ; CHECK-NEXT: local.set 1
 call void @inhibit_store_to_load_forwarding()
 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
 %reloaded = load float, %f32_cell %retval
 ; CHECK-NEXT: local.get 1
 ; CHECK-NEXT: end_function
 ret float %reloaded
}

define double @ir_local_f64(double %arg) {
 ; CHECK-LABEL: ir_local_f64:
 ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
 %retval = alloca double, addrspace(1)
 ; CHECK-NEXT: .local f64
 store double %arg, %f64_cell %retval
 ; CHECK-NEXT: local.get 0
 ; CHECK-NEXT: local.set 1
 call void @inhibit_store_to_load_forwarding()
 ; CHECK-NEXT: call inhibit_store_to_load_forwarding
 %reloaded = load double, %f64_cell %retval
 ; CHECK-NEXT: local.get 1
 ; CHECK-NEXT: end_function
 ret double %reloaded
}

define void @ir_unreferenced_local() {
 ; CHECK-LABEL: ir_unreferenced_local:
 ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
 %unused = alloca i32, addrspace(1)
 ; CHECK-NEXT: .local i32
 ret void
 ; CHECK-NEXT: end_function
}