aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2024-01-25 09:48:38 -0800
committerGitHub <noreply@github.com>2024-01-25 09:48:38 -0800
commit7f409cd82b322038f08a984a07377758e76b0e4c (patch)
tree84f9327a3a41423a37abd8852d40d743911a9ba6 /llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
parent7fdb932c4e78706cec3468a1f149e5a54a865d36 (diff)
downloadllvm-7f409cd82b322038f08a984a07377758e76b0e4c.zip
llvm-7f409cd82b322038f08a984a07377758e76b0e4c.tar.gz
llvm-7f409cd82b322038f08a984a07377758e76b0e4c.tar.bz2
[Object][Wasm] Allow parsing of GC types in type and table sections (#79235)
This change allows a WasmObjectFile to be created from a wasm file even if it uses typed funcrefs and GC types. It does not significantly change how lib/Object models its various internal types (e.g. WasmSignature, WasmElemSegment), so LLVM does not really "support" or understand such files, but it is sufficient to parse the type, global and element sections, discarding types that are not understood. This is useful for low-level binary tools such as nm and objcopy, which use only limited aspects of the binary (such as function definitions) or deal with sections as opaque blobs. This is done by allowing `WasmValType` to have a value of `OTHERREF` (representing any unmodeled reference type), and adding a field to `WasmSignature` indicating it's a placeholder for an unmodeled reference type (since there is a 1:1 correspondence between WasmSignature objects and types in the type section). Then the object file parsers for the type and element sections are expanded to parse encoded reference types and discard any unmodeled fields.
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index 908efbb..fb949d4 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -125,8 +125,9 @@ static char getInvokeSig(wasm::ValType VT) {
return 'F';
case wasm::ValType::EXTERNREF:
return 'X';
+ default:
+ llvm_unreachable("Unhandled wasm::ValType enum");
}
- llvm_unreachable("Unhandled wasm::ValType enum");
}
// Given the wasm signature, generate the invoke name in the format JS glue code