[PATCH] D65177: [WebAssembly] Set __tls_align to 1 when there is no TLS
Guanzhong Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 14:47:54 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366948: [WebAssembly] Set __tls_align to 1 when there is no TLS (authored by quantum, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D65177?vs=211593&id=211604#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65177/new/
https://reviews.llvm.org/D65177
Files:
lld/trunk/test/wasm/no-tls.test
lld/trunk/wasm/Driver.cpp
Index: lld/trunk/test/wasm/no-tls.test
===================================================================
--- lld/trunk/test/wasm/no-tls.test
+++ lld/trunk/test/wasm/no-tls.test
@@ -0,0 +1,41 @@
+; Testing that __tls_size and __tls_align are correctly emitted when there are
+; no thread_local variables.
+
+RUN: llc -mattr=+bulk-memory -filetype=obj %p/Inputs/start.ll -o %t.o
+
+RUN: wasm-ld -no-gc-sections --shared-memory --max-memory=131072 --allow-undefined -o %t.wasm %t.o
+RUN: obj2yaml %t.wasm | FileCheck %s
+CHECK: - Type: GLOBAL
+CHECK-NEXT: Globals:
+
+; __stack_pointer
+CHECK-NEXT: - Index: 0
+CHECK-NEXT: Type: I32
+CHECK-NEXT: Mutable: true
+CHECK-NEXT: InitExpr:
+CHECK-NEXT: Opcode: I32_CONST
+CHECK-NEXT: Value: 66560
+
+; __tls_base
+CHECK-NEXT: - Index: 1
+CHECK-NEXT: Type: I32
+CHECK-NEXT: Mutable: true
+CHECK-NEXT: InitExpr:
+CHECK-NEXT: Opcode: I32_CONST
+CHECK-NEXT: Value: 0
+
+; __tls_size
+CHECK-NEXT: - Index: 2
+CHECK-NEXT: Type: I32
+CHECK-NEXT: Mutable: false
+CHECK-NEXT: InitExpr:
+CHECK-NEXT: Opcode: I32_CONST
+CHECK-NEXT: Value: 0
+
+; __tls_align
+CHECK-NEXT: - Index: 3
+CHECK-NEXT: Type: I32
+CHECK-NEXT: Mutable: false
+CHECK-NEXT: InitExpr:
+CHECK-NEXT: Opcode: I32_CONST
+CHECK-NEXT: Value: 1
Index: lld/trunk/wasm/Driver.cpp
===================================================================
--- lld/trunk/wasm/Driver.cpp
+++ lld/trunk/wasm/Driver.cpp
@@ -450,10 +450,11 @@
return sym;
}
-static GlobalSymbol *createGlobalVariable(StringRef name, bool isMutable) {
+static GlobalSymbol *createGlobalVariable(StringRef name, bool isMutable,
+ int value) {
llvm::wasm::WasmGlobal wasmGlobal;
wasmGlobal.Type = {WASM_TYPE_I32, isMutable};
- wasmGlobal.InitExpr.Value.Int32 = 0;
+ wasmGlobal.InitExpr.Value.Int32 = value;
wasmGlobal.InitExpr.Opcode = WASM_OPCODE_I32_CONST;
wasmGlobal.SymbolName = name;
return symtab->addSyntheticGlobal(name, WASM_SYMBOL_VISIBILITY_HIDDEN,
@@ -527,9 +528,9 @@
}
if (config->sharedMemory && !config->shared) {
- WasmSym::tlsBase = createGlobalVariable("__tls_base", true);
- WasmSym::tlsSize = createGlobalVariable("__tls_size", false);
- WasmSym::tlsAlign = createGlobalVariable("__tls_align", false);
+ WasmSym::tlsBase = createGlobalVariable("__tls_base", true, 0);
+ WasmSym::tlsSize = createGlobalVariable("__tls_size", false, 0);
+ WasmSym::tlsAlign = createGlobalVariable("__tls_align", false, 1);
WasmSym::initTLS = symtab->addSyntheticFunction(
"__wasm_init_tls", WASM_SYMBOL_VISIBILITY_HIDDEN,
make<SyntheticFunction>(i32ArgSignature, "__wasm_init_tls"));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65177.211604.patch
Type: text/x-patch
Size: 3046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190724/6ae536e3/attachment.bin>
More information about the llvm-commits
mailing list