Index: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def =================================================================== --- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def +++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def @@ -31,7 +31,7 @@ // Thread-local storage TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory") -TARGET_BUILTIN(__builtin_wasm_tls_base, "v*", "n", "bulk-memory") +TARGET_BUILTIN(__builtin_wasm_tls_base, "v*", "nU", "bulk-memory") // Floating point min/max BUILTIN(__builtin_wasm_min_f32, "fff", "nc") Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp @@ -235,7 +235,7 @@ assert(PtrVT == MVT::i32 && "only wasm32 is supported for now"); MachineSDNode *TLSBase = CurDAG->getMachineNode( - WebAssembly::GLOBAL_GET_I32, DL, MVT::i32, + WebAssembly::GLOBAL_GET_I32, DL, MVT::i32, MVT::Other, CurDAG->getTargetExternalSymbol("__tls_base", PtrVT), Node->getOperand(0)); ReplaceNode(Node, TLSBase); Index: llvm/trunk/test/CodeGen/WebAssembly/tls-general-dynamic.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/tls-general-dynamic.ll +++ llvm/trunk/test/CodeGen/WebAssembly/tls-general-dynamic.ll @@ -84,6 +84,17 @@ ret i8* %1 } +; CHECK-LABEL: tls_base_write: +; CHECK-NEXT: .functype tls_base_write (i32) -> () +define void @tls_base_write(i8** %output) { +; CHECK-NEXT: global.get __tls_base +; CHECK-NEXT: i32.store 0 +; CHECK-NEXT: return + %1 = call i8* @llvm.wasm.tls.base() + store i8* %1, i8** %output + ret void +} + ; CHECK: .type tls,@object ; TLS-NEXT: .section .tbss.tls,"",@ ; NO-TLS-NEXT: .section .bss.tls,"",@