diff options
| author | Luuk de Gram <luuk@degram.dev> | 2022-04-17 19:41:05 +0200 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2022-04-19 19:58:49 +0200 |
| commit | be08d2bdbd2f64ccb9ef0f985a57a4bf89b9aebb (patch) | |
| tree | 727d36adc443701b6aa8221797dc082f3670a290 /src/arch/wasm/CodeGen.zig | |
| parent | 2193f7c4a2b56f67bf07d27c3f715cf3969c392f (diff) | |
| download | zig-be08d2bdbd2f64ccb9ef0f985a57a4bf89b9aebb.tar.gz zig-be08d2bdbd2f64ccb9ef0f985a57a4bf89b9aebb.zip | |
wasm: Fix unreachable paths
When the last instruction is a debug instruction, the type of it is void.
Similarly for 'noreturn' emit an 'unreachable' instruction to tell the wasm-validator
the path cannot be reached.
Also respect the '--strip' flag in the self-hosted wasm linker and not emit a 'name' section
when the flag is set to `true`.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index b701299e73..6cec3f4a87 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -871,7 +871,8 @@ fn genFunc(self: *Self) InnerError!void { // we emit an unreachable instruction to tell the stack validator that part will never be reached. if (func_type.returns.len != 0 and self.air.instructions.len > 0) { const inst = @intCast(u32, self.air.instructions.len - 1); - if (self.air.typeOfIndex(inst).isNoReturn()) { + const last_inst_ty = self.air.typeOfIndex(inst); + if (!last_inst_ty.hasRuntimeBitsIgnoreComptime() or last_inst_ty.isNoReturn()) { try self.addTag(.@"unreachable"); } } |
