[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
Tue Jul 23 17:58:17 PDT 2019
quantum updated this revision to Diff 211393.
quantum added a comment.
Switched to not using default arguments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65177/new/
https://reviews.llvm.org/D65177
Files:
lld/test/wasm/no-tls.test
lld/wasm/Driver.cpp
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/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"));
Index: lld/test/wasm/no-tls.test
===================================================================
--- /dev/null
+++ lld/test/wasm/no-tls.test
@@ -0,0 +1,38 @@
+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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65177.211393.patch
Type: text/x-patch
Size: 2882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190724/966525a3/attachment.bin>
More information about the llvm-commits
mailing list