-
- Downloads
[WebAssembly] Make EH/SjLj vars unconditionally thread local
This makes three thread local variables (`__THREW__`, `__threwValue`, and `__wasm_lpad_context`) unconditionally thread local. If the target doesn't support TLS, they will be downgraded to normal variables in `stripThreadLocals`. This makes the object not linkable with other objects using shared memory, which is what we intend here; these variables should be thread local when used with shared memory. This is what we initially tried in D88262. But D88323 changed this: It only created these variables when threads were supported, because `__THREW__` and `__threwValue` were always generated even if Emscripten EH/SjLj was not used, making all objects built without threads not linkable with shared memory, which was too restrictive. But sometimes this is not safe. If we build an object using variables such as `__THREW__` without threads, it can be linked to other objects using shared memory, because the original object's `__THREW__` was not created thread local to begin with. So this CL basically reverts D88323 with some additional improvements: - This checks each of the functions and global variables created within `LowerEmscriptenEHSjLj` pass and removes it if it's not used at the end of the pass. So only modules using those variables will be affected. - Moves `CoalesceFeaturesAndStripAtomics` and `AtomicExpand` passes after all other IR pasess that can create thread local variables. It is not sufficient to move them to the end of `addIRPasses`, because `__wasm_lpad_context` is created in `WasmEHPrepare`, which runs inside `addPassesToHandleExceptions`, which runs before `addISelPrepare`. So we override `addISelPrepare` and move atomic/TLS stripping and expanding passes there. This also removes merges `TLS` and `NO-TLS` FileCheck lines into one `CHECK` line, because in the bitcode level we always create them as thread local. Also some function declarations are deleted `CHECK` lines because they are unused. Reviewed By: tlively, sbc100 Differential Revision: https://reviews.llvm.org/D120013
Showing
- llvm/lib/CodeGen/WasmEHPrepare.cpp 5 additions, 11 deletionsllvm/lib/CodeGen/WasmEHPrepare.cpp
- llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp 19 additions, 28 deletions...b/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp 11 additions, 6 deletionsllvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
- llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll 6 additions, 8 deletionsllvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
- llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll 5 additions, 7 deletionsllvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
- llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll 7 additions, 8 deletionsllvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
- llvm/test/CodeGen/WebAssembly/wasmehprepare.ll 3 additions, 4 deletionsllvm/test/CodeGen/WebAssembly/wasmehprepare.ll
Loading
Please register or sign in to comment