Changeset View
Standalone View
lld/test/wasm/tls.ll
- This file was added.
; RUN: llc -mattr=+bulk-memory -filetype=obj %s -o %t.o | |||||
target triple = "wasm32-unknown-unknown" | |||||
@tls1 = thread_local(localexec) global i32 1, align 4 | |||||
@tls2 = thread_local(localexec) global i32 1, align 4 | |||||
aheejin: Can we possibly mix one non-tls global variable between `tls1` and `tls2`, just to see they… | |||||
Done. quantum: Done. | |||||
define i32* @tls1_addr() { | |||||
ret i32* @tls1 | |||||
} | |||||
define i32* @tls2_addr() { | |||||
ret i32* @tls2 | |||||
} | |||||
; RUN: wasm-ld -no-gc-sections --allow-undefined --no-entry -o %t.wasm %t.o | |||||
; RUN: obj2yaml %t.wasm | FileCheck %s | |||||
; CHECK: - Type: GLOBAL | |||||
; CHECK-NEXT: Globals: | |||||
; CHECK-NEXT: - Index: 0 | |||||
; CHECK-NEXT: Type: I32 | |||||
; CHECK-NEXT: Mutable: true | |||||
; CHECK-NEXT: InitExpr: | |||||
; CHECK-NEXT: Opcode: I32_CONST | |||||
; CHECK-NEXT: Value: 66576 | |||||
; CHECK-NEXT: - Index: 1 | |||||
; CHECK-NEXT: Type: I32 | |||||
; CHECK-NEXT: Mutable: true | |||||
; CHECK-NEXT: InitExpr: | |||||
; CHECK-NEXT: Opcode: I32_CONST | |||||
; CHECK-NEXT: Value: 0 | |||||
; CHECK-NEXT: - Index: 2 | |||||
; CHECK-NEXT: Type: I32 | |||||
; CHECK-NEXT: Mutable: false | |||||
; CHECK-NEXT: InitExpr: | |||||
; CHECK-NEXT: Opcode: I32_CONST | |||||
; CHECK-NEXT: Value: 8 | |||||
; CHECK: - Type: CODE | |||||
; CHECK-NEXT: Functions: | |||||
; CHECK-NEXT: - Index: 0 | |||||
; CHECK-NEXT: Locals: [] | |||||
; CHECK-NEXT: Body: 0B | |||||
; CHECK-NEXT: - Index: 1 | |||||
; CHECK-NEXT: Locals: [] | |||||
; CHECK-NEXT: Body: 20002401200041004108FC0800000B | |||||
; Expected body of __wasm_init_tls: | |||||
; local.get 0 | |||||
; global.set 1 | |||||
; local.get 0 | |||||
; i32.const 0 | |||||
; i32.const 8 | |||||
; memory.init 0, 0 | |||||
; end | |||||
Hmm, I think there might be a way to actually print disassembly results. There are '*.test' files in test directory, in which we have some examples. For example, this test has a sequence of commands you want to run, and you can put input files in a separate directory. That test uses obj2yaml, but can we possibly use llvm-objdump or something to disassemble? aheejin: Hmm, I think there might be a way to actually print disassembly results. There are '*.test'… | |||||
We already know that we can do something like Run: obj2yaml %t.wasm | sed -n '/Body:/{s/^\s*Body:\s*//;s/../0x& /gp}' | llvm-mc -disassemble -triple=wasm32 to compare the actual assembly. As for llvm-objdump, it seems to be unable to disassemble the WASM properly: .../tools/lld/test/wasm/Output/tls.ll.tmp.wasm: file format WASM Disassembly of section CODE: 00000000 CODE: # 4 functions in section. 1: 02 00 block invalid_type 3: 0b end 4: 10 00 call 0 6: 20 00 local.get 0 8: 24 01 global.set 1 a: 20 00 local.get 0 c: 41 00 i32.const 0 e: 41 08 i32.const 8 10: fc 08 00 00 memory.init 0, 0 14: 0b end 15: 0f return 16: 00 llvm-objdump: lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc:2032: void llvm::WebAssemblyInstPrinter::printInstruction(const llvm::MCInst *, llvm::raw_ostream &): Assertion `Bits != 0 && "Cannot print this instruction."' failed. quantum: We already know that we can do something like
Run: obj2yaml %t.wasm | sed -n '/Body… | |||||
It might be worth filing an LLVM bug for this (or possibly fixing in a separate CL). tlively: It might be worth filing an LLVM bug for this (or possibly fixing in a separate CL). | |||||
Going to fix this at some point in the future. quantum: Going to fix this at some point in the future. | |||||
This is known issue with the disassembler in that it doesn't know where the functions start and stop in executable output, only in object files. sbc100: This is known issue with the disassembler in that it doesn't know where the functions start and… | |||||
; CHECK-NEXT: - Index: 2 | |||||
; CHECK-NEXT: Locals: [] | |||||
; CHECK-NEXT: Body: 2381808080004180808080006A0B | |||||
; Expected body of tls1_addr: | |||||
; global.get 1 | |||||
; i32.const 0 | |||||
; i32.add | |||||
; end | |||||
; CHECK-NEXT: - Index: 3 | |||||
; CHECK-NEXT: Locals: [] | |||||
; CHECK-NEXT: Body: 2381808080004184808080006A0B | |||||
; Expected body of tls1_addr: | |||||
; global.get 1 | |||||
; i32.const 4 | |||||
; i32.add | |||||
; end |
Can we possibly mix one non-tls global variable between tls1 and tls2, just to see they work together?