From: Guanzhong Chen Date: Thu, 18 Jul 2019 21:17:52 +0000 (+0000) Subject: [WebAssembly] Fix __builtin_wasm_tls_base intrinsic X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df4479200b399a8bc4054ab44cfb40a2a6e44bd8;p=platform%2Fupstream%2Fllvm.git [WebAssembly] Fix __builtin_wasm_tls_base intrinsic Summary: Properly generate the outchain for the `__builtin_wasm_tls_base` intrinsic. Also marked the intrinsic pure, per @sunfish's suggestion. Reviewers: tlively, aheejin, sbc100, sunfish Reviewed By: tlively Subscribers: dschuff, jgravelle-google, hiraditya, cfe-commits, llvm-commits, sunfish Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D64949 llvm-svn: 366499 --- diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def index 68cecdf..0c0ca9e 100644 --- a/clang/include/clang/Basic/BuiltinsWebAssembly.def +++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def @@ -31,7 +31,7 @@ TARGET_BUILTIN(__builtin_wasm_data_drop, "vIUi", "", "bulk-memory") // 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") diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp index e57e194..aaf3259 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp @@ -235,7 +235,7 @@ void WebAssemblyDAGToDAGISel::Select(SDNode *Node) { 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); diff --git a/llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll b/llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll index 975e2ce..f121d62 100644 --- a/llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll +++ b/llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll @@ -84,6 +84,17 @@ define i8* @tls_base() { 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,"",@