File: offset-folding.ll

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (62 lines) | stat: -rw-r--r-- 1,874 bytes parent folder | download | duplicates (7)
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
; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s

; Test that constant offsets can be folded into global addresses.

target triple = "wasm32-unknown-unknown"

@x = external dso_local global [0 x i32]
@y = dso_local global [50 x i32] zeroinitializer

; Test basic constant offsets of both defined and external symbols.

; CHECK-LABEL: test0:
; CHECK-NEXT: .functype test0 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, x+188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define dso_local i32* @test0() {
  ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 47)
}

; CHECK-LABEL: test1:
; CHECK-NEXT: .functype test1 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, y+188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define dso_local i32* @test1() {
  ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 47)
}

; Test zero offsets.

; CHECK-LABEL: test2:
; CHECK-NEXT: .functype test2 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, x{{$}}
; CHECK=NEXT: return $pop0{{$}}
define dso_local i32* @test2() {
  ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 0)
}

; CHECK-LABEL: test3:
; CHECK-NEXT: .functype test3 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, y{{$}}
; CHECK=NEXT: return $pop0{{$}}
define dso_local i32* @test3() {
  ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 0)
}

; Test negative offsets.

; CHECK-LABEL: test4:
; CHECK-NEXT: .functype test4 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, x-188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define dso_local i32* @test4() {
  ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 -47)
}

; CHECK-LABEL: test5:
; CHECK-NEXT: .functype test5 () -> (i32){{$}}
; CHECK-NEXT: i32.const $push0=, y-188{{$}}
; CHECK=NEXT: return $pop0{{$}}
define dso_local i32* @test5() {
  ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 -47)
}