2017-03-01 07:37:04 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s
|
2015-08-27 06:09:54 +08:00
|
|
|
|
|
|
|
; Test that globals assemble as expected.
|
|
|
|
|
2016-01-07 11:19:23 +08:00
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2017-03-01 07:37:04 +08:00
|
|
|
target triple = "wasm32-unknown-unknown-wasm"
|
2015-08-27 06:09:54 +08:00
|
|
|
|
|
|
|
; CHECK-NOT: llvm.used
|
|
|
|
; CHECK-NOT: llvm.metadata
|
|
|
|
@llvm.used = appending global [1 x i32*] [i32* @g], section "llvm.metadata"
|
|
|
|
|
2015-11-17 08:20:44 +08:00
|
|
|
; CHECK: foo:
|
2015-12-16 06:01:29 +08:00
|
|
|
; CHECK: i32.const $push0=, 0{{$}}
|
|
|
|
; CHECK-NEXT: i32.load $push1=, answer($pop0){{$}}
|
2015-11-26 00:55:01 +08:00
|
|
|
; CHECK-NEXT: return $pop1{{$}}
|
2015-11-17 08:20:44 +08:00
|
|
|
define i32 @foo() {
|
|
|
|
%a = load i32, i32* @answer
|
|
|
|
ret i32 %a
|
|
|
|
}
|
|
|
|
|
2015-11-26 00:44:29 +08:00
|
|
|
; CHECK-LABEL: call_memcpy:
|
|
|
|
; CHECK-NEXT: .param i32, i32, i32{{$}}
|
|
|
|
; CHECK-NEXT: .result i32{{$}}
|
2016-01-26 12:01:11 +08:00
|
|
|
; CHECK-NEXT: i32.call $push0=, memcpy@FUNCTION, $0, $1, $2{{$}}
|
|
|
|
; CHECK-NEXT: return $pop0{{$}}
|
2015-11-26 00:44:29 +08:00
|
|
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1)
|
|
|
|
define i8* @call_memcpy(i8* %p, i8* nocapture readonly %q, i32 %n) {
|
|
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %p, i8* %q, i32 %n, i32 1, i1 false)
|
|
|
|
ret i8* %p
|
|
|
|
}
|
|
|
|
|
2016-01-07 11:19:23 +08:00
|
|
|
; CHECK: .type .Lg,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
2016-01-07 11:19:23 +08:00
|
|
|
; CHECK-NEXT: .Lg:
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: .int32 1337{{$}}
|
2016-01-07 11:19:23 +08:00
|
|
|
; CHECK-NEXT: .size .Lg, 4{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
@g = private global i32 1337
|
|
|
|
|
|
|
|
; CHECK-LABEL: ud:
|
2016-01-08 07:18:29 +08:00
|
|
|
; CHECK-NEXT: .skip 4{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: .size ud, 4{{$}}
|
|
|
|
@ud = internal global i32 undef
|
|
|
|
|
|
|
|
; CHECK: .type nil,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 2
|
|
|
|
; CHECK: nil:
|
|
|
|
; CHECK: .int32 0
|
|
|
|
; CHECK: .size nil, 4
|
2015-10-06 08:27:55 +08:00
|
|
|
@nil = internal global i32 zeroinitializer
|
|
|
|
|
|
|
|
; CHECK: .type z,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 2
|
|
|
|
; CHECK: z:
|
|
|
|
; CHECK: .int32 0
|
|
|
|
; CHECK: .size z, 4
|
2015-10-06 08:27:55 +08:00
|
|
|
@z = internal global i32 0
|
|
|
|
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .type one,@object
|
|
|
|
; CHECK: .p2align 2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: one:
|
|
|
|
; CHECK-NEXT: .int32 1{{$}}
|
|
|
|
; CHECK-NEXT: .size one, 4{{$}}
|
|
|
|
@one = internal global i32 1
|
|
|
|
|
|
|
|
; CHECK: .type answer,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: answer:
|
|
|
|
; CHECK-NEXT: .int32 42{{$}}
|
|
|
|
; CHECK-NEXT: .size answer, 4{{$}}
|
|
|
|
@answer = internal global i32 42
|
|
|
|
|
|
|
|
; CHECK: .type u32max,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: u32max:
|
|
|
|
; CHECK-NEXT: .int32 4294967295{{$}}
|
|
|
|
; CHECK-NEXT: .size u32max, 4{{$}}
|
|
|
|
@u32max = internal global i32 -1
|
|
|
|
|
|
|
|
; CHECK: .type ud64,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: ud64:
|
2016-01-08 07:18:29 +08:00
|
|
|
; CHECK-NEXT: .skip 8{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: .size ud64, 8{{$}}
|
|
|
|
@ud64 = internal global i64 undef
|
|
|
|
|
|
|
|
; CHECK: .type nil64,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
|
|
|
; CHECK-NEXT: nil64:
|
|
|
|
; CHECK-NEXT: .int64 0{{$}}
|
|
|
|
; CHECK-NEXT: .size nil64, 8{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
@nil64 = internal global i64 zeroinitializer
|
|
|
|
|
|
|
|
; CHECK: .type z64,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
|
|
|
; CHECK-NEXT: z64:
|
|
|
|
; CHECK-NEXT: .int64 0{{$}}
|
|
|
|
; CHECK-NEXT: .size z64, 8{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
@z64 = internal global i64 0
|
|
|
|
|
|
|
|
; CHECK: .type twoP32,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: twoP32:
|
|
|
|
; CHECK-NEXT: .int64 4294967296{{$}}
|
|
|
|
; CHECK-NEXT: .size twoP32, 8{{$}}
|
|
|
|
@twoP32 = internal global i64 4294967296
|
|
|
|
|
|
|
|
; CHECK: .type u64max,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: u64max:
|
|
|
|
; CHECK-NEXT: .int64 -1{{$}}
|
|
|
|
; CHECK-NEXT: .size u64max, 8{{$}}
|
|
|
|
@u64max = internal global i64 -1
|
|
|
|
|
|
|
|
; CHECK: .type f32ud,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: f32ud:
|
2016-01-08 07:18:29 +08:00
|
|
|
; CHECK-NEXT: .skip 4{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: .size f32ud, 4{{$}}
|
|
|
|
@f32ud = internal global float undef
|
|
|
|
|
|
|
|
; CHECK: .type f32nil,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
|
|
|
; CHECK-NEXT: f32nil:
|
|
|
|
; CHECK-NEXT: .int32 0{{$}}
|
|
|
|
; CHECK-NEXT: .size f32nil, 4{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
@f32nil = internal global float zeroinitializer
|
|
|
|
|
|
|
|
; CHECK: .type f32z,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
|
|
|
; CHECK-NEXT: f32z:
|
|
|
|
; CHECK-NEXT: .int32 0{{$}}
|
|
|
|
; CHECK-NEXT: .size f32z, 4{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
@f32z = internal global float 0.0
|
|
|
|
|
|
|
|
; CHECK: .type f32nz,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK: f32nz:
|
|
|
|
; CHECK: .int32 2147483648{{$}}
|
|
|
|
; CHECK: .size f32nz, 4{{$}}
|
|
|
|
@f32nz = internal global float -0.0
|
|
|
|
|
|
|
|
; CHECK: .type f32two,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 2{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: f32two:
|
|
|
|
; CHECK-NEXT: .int32 1073741824{{$}}
|
|
|
|
; CHECK-NEXT: .size f32two, 4{{$}}
|
|
|
|
@f32two = internal global float 2.0
|
|
|
|
|
|
|
|
; CHECK: .type f64ud,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: f64ud:
|
2016-01-08 07:18:29 +08:00
|
|
|
; CHECK-NEXT: .skip 8{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: .size f64ud, 8{{$}}
|
|
|
|
@f64ud = internal global double undef
|
|
|
|
|
|
|
|
; CHECK: .type f64nil,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
|
|
|
; CHECK-NEXT: f64nil:
|
|
|
|
; CHECK-NEXT: .int64 0{{$}}
|
|
|
|
; CHECK-NEXT: .size f64nil, 8{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
@f64nil = internal global double zeroinitializer
|
|
|
|
|
|
|
|
; CHECK: .type f64z,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
|
|
|
; CHECK-NEXT: f64z:
|
|
|
|
; CHECK-NEXT: .int64 0{{$}}
|
|
|
|
; CHECK-NEXT: .size f64z, 8{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
@f64z = internal global double 0.0
|
|
|
|
|
|
|
|
; CHECK: .type f64nz,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: f64nz:
|
|
|
|
; CHECK-NEXT: .int64 -9223372036854775808{{$}}
|
|
|
|
; CHECK-NEXT: .size f64nz, 8{{$}}
|
|
|
|
@f64nz = internal global double -0.0
|
|
|
|
|
|
|
|
; CHECK: .type f64two,@object
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 3{{$}}
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-NEXT: f64two:
|
|
|
|
; CHECK-NEXT: .int64 4611686018427387904{{$}}
|
|
|
|
; CHECK-NEXT: .size f64two, 8{{$}}
|
|
|
|
@f64two = internal global double 2.0
|
2015-12-15 10:02:51 +08:00
|
|
|
|
|
|
|
; Indexing into a global array produces a relocation.
|
|
|
|
; CHECK: .type arr,@object
|
|
|
|
; CHECK: .type ptr,@object
|
|
|
|
; CHECK: ptr:
|
|
|
|
; CHECK-NEXT: .int32 arr+80
|
|
|
|
; CHECK-NEXT: .size ptr, 4
|
|
|
|
@arr = global [128 x i32] zeroinitializer, align 16
|
|
|
|
@ptr = global i32* getelementptr inbounds ([128 x i32], [128 x i32]* @arr, i32 0, i32 20), align 4
|
2015-12-18 04:50:45 +08:00
|
|
|
|
|
|
|
; Constant global.
|
|
|
|
; CHECK: .type rom,@object{{$}}
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: .section .rodata.rom,
|
2015-12-18 04:50:45 +08:00
|
|
|
; CHECK: .globl rom{{$}}
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 4{{$}}
|
2015-12-18 04:50:45 +08:00
|
|
|
; CHECK: rom:
|
2016-01-08 07:18:29 +08:00
|
|
|
; CHECK: .skip 512{{$}}
|
2015-12-18 04:50:45 +08:00
|
|
|
; CHECK: .size rom, 512{{$}}
|
|
|
|
@rom = constant [128 x i32] zeroinitializer, align 16
|
2016-01-14 03:29:37 +08:00
|
|
|
|
|
|
|
; CHECK: .type array,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK: array:
|
2016-01-14 03:29:37 +08:00
|
|
|
; CHECK-NEXT: .skip 8
|
|
|
|
; CHECK-NEXT: .size array, 8
|
|
|
|
; CHECK: .type pointer_to_array,@object
|
2017-03-01 07:37:04 +08:00
|
|
|
; CHECK-NEXT: .section .data.rel.ro.pointer_to_array,
|
2016-01-14 03:29:37 +08:00
|
|
|
; CHECK-NEXT: .globl pointer_to_array
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK-NEXT: .p2align 2
|
2016-01-14 03:29:37 +08:00
|
|
|
; CHECK-NEXT: pointer_to_array:
|
|
|
|
; CHECK-NEXT: .int32 array+4
|
|
|
|
; CHECK-NEXT: .size pointer_to_array, 4
|
|
|
|
@array = internal constant [8 x i8] zeroinitializer, align 1
|
|
|
|
@pointer_to_array = constant i8* getelementptr inbounds ([8 x i8], [8 x i8]* @array, i32 0, i32 4), align 4
|
2017-12-07 08:14:30 +08:00
|
|
|
|
|
|
|
; Handle external objects with opaque type.
|
|
|
|
%struct.ASTRUCT = type opaque
|
|
|
|
@g_struct = external global %struct.ASTRUCT, align 1
|
|
|
|
define i32 @address_of_opaque() {
|
|
|
|
ret i32 ptrtoint (%struct.ASTRUCT* @g_struct to i32)
|
|
|
|
}
|