brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 41b7387 Raw
63 lines · plain
1; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s2 3; Test that constant offsets can be folded into global addresses.4 5target triple = "wasm32-unknown-unknown"6 7@x = external dso_local global [0 x i32]8@y = dso_local global [50 x i32] zeroinitializer9 10; Test basic constant offsets of both defined and external symbols.11 12; CHECK-LABEL: test0:13; CHECK-NEXT: .functype test0 () -> (i32){{$}}14; CHECK-NEXT: i32.const $push0=, x+188{{$}}15; CHECK=NEXT: return $pop0{{$}}16define dso_local ptr @test0() {17  ret ptr getelementptr ([0 x i32], ptr @x, i32 0, i32 47)18}19 20; CHECK-LABEL: test1:21; CHECK-NEXT: .functype test1 () -> (i32){{$}}22; CHECK-NEXT: i32.const $push0=, y+188{{$}}23; CHECK=NEXT: return $pop0{{$}}24define dso_local ptr @test1() {25  ret ptr getelementptr ([50 x i32], ptr @y, i32 0, i32 47)26}27 28; Test zero offsets.29 30; CHECK-LABEL: test2:31; CHECK-NEXT: .functype test2 () -> (i32){{$}}32; CHECK-NEXT: i32.const $push0=, x{{$}}33; CHECK=NEXT: return $pop0{{$}}34define dso_local ptr @test2() {35  ret ptr @x36}37 38; CHECK-LABEL: test3:39; CHECK-NEXT: .functype test3 () -> (i32){{$}}40; CHECK-NEXT: i32.const $push0=, y{{$}}41; CHECK=NEXT: return $pop0{{$}}42define dso_local ptr @test3() {43  ret ptr @y44}45 46; Test negative offsets.47 48; CHECK-LABEL: test4:49; CHECK-NEXT: .functype test4 () -> (i32){{$}}50; CHECK-NEXT: i32.const $push0=, x-188{{$}}51; CHECK=NEXT: return $pop0{{$}}52define dso_local ptr @test4() {53  ret ptr getelementptr ([0 x i32], ptr @x, i32 0, i32 -47)54}55 56; CHECK-LABEL: test5:57; CHECK-NEXT: .functype test5 () -> (i32){{$}}58; CHECK-NEXT: i32.const $push0=, y-188{{$}}59; CHECK=NEXT: return $pop0{{$}}60define dso_local ptr @test5() {61  ret ptr getelementptr ([50 x i32], ptr @y, i32 0, i32 -47)62}63