mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-27 06:54:30 +00:00
[WebAssembly] Implement __builtin_wasm_tls_base intrinsic
Summary: Add `__builtin_wasm_tls_base` so that LeakSanitizer can find the thread-local block and scan through it for memory leaks. Reviewers: tlively, aheejin, sbc100 Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D64900 llvm-svn: 366475
This commit is contained in:
parent
9e600b667f
commit
06b4c69d40
@ -133,4 +133,9 @@ def int_wasm_tls_size :
|
||||
[],
|
||||
[IntrNoMem, IntrSpeculatable]>;
|
||||
|
||||
def int_wasm_tls_base :
|
||||
Intrinsic<[llvm_ptr_ty],
|
||||
[],
|
||||
[IntrReadMem]>;
|
||||
|
||||
} // TargetPrefix = "wasm"
|
||||
|
@ -227,6 +227,23 @@ void WebAssemblyDAGToDAGISel::Select(SDNode *Node) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ISD::INTRINSIC_W_CHAIN: {
|
||||
unsigned IntNo = cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue();
|
||||
switch (IntNo) {
|
||||
case Intrinsic::wasm_tls_base: {
|
||||
MVT PtrVT = TLI->getPointerTy(CurDAG->getDataLayout());
|
||||
assert(PtrVT == MVT::i32 && "only wasm32 is supported for now");
|
||||
|
||||
MachineSDNode *TLSBase = CurDAG->getMachineNode(
|
||||
WebAssembly::GLOBAL_GET_I32, DL, MVT::i32,
|
||||
CurDAG->getTargetExternalSymbol("__tls_base", PtrVT),
|
||||
Node->getOperand(0));
|
||||
ReplaceNode(Node, TLSBase);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -75,6 +75,15 @@ define i32 @tls_size() {
|
||||
ret i32 %1
|
||||
}
|
||||
|
||||
; CHECK-LABEL: tls_base:
|
||||
; CHECK-NEXT: .functype tls_base () -> (i32)
|
||||
define i8* @tls_base() {
|
||||
; CHECK-NEXT: global.get __tls_base
|
||||
; CHECK-NEXT: return
|
||||
%1 = call i8* @llvm.wasm.tls.base()
|
||||
ret i8* %1
|
||||
}
|
||||
|
||||
; CHECK: .type tls,@object
|
||||
; TLS-NEXT: .section .tbss.tls,"",@
|
||||
; NO-TLS-NEXT: .section .bss.tls,"",@
|
||||
@ -84,3 +93,4 @@ define i32 @tls_size() {
|
||||
@tls = internal thread_local global i32 0
|
||||
|
||||
declare i32 @llvm.wasm.tls.size.i32()
|
||||
declare i8* @llvm.wasm.tls.base()
|
||||
|
Loading…
x
Reference in New Issue
Block a user