WebAssembly: test global array indexing
authorJF Bastien <jfb@google.com>
Tue, 15 Dec 2015 02:02:51 +0000 (02:02 +0000)
committerJF Bastien <jfb@google.com>
Tue, 15 Dec 2015 02:02:51 +0000 (02:02 +0000)
This case was tested in the linker from code, but not from globals indexing into other globals. The linker currently barfs on this, ncbray volunteered to fix it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255601 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/WebAssembly/global.ll

index e00d32b972ecbd048e7d8e80b9143b22271330a5..c6bc359a188edd2c25b387e67a17658491c2e172 100644 (file)
@@ -156,3 +156,12 @@ define i8* @call_memcpy(i8* %p, i8* nocapture readonly %q, i32 %n) {
 ; CHECK-NEXT: .int64 4611686018427387904{{$}}
 ; CHECK-NEXT: .size f64two, 8{{$}}
 @f64two = internal global double 2.0
+
+; 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