Skip to content

Duplicated WASM unreachable instructions #102132

Open
@Expyron

Description

@Expyron

Targets: wasm32-unknown-unknown, wasm32-wasi

When calling core::arch::wasm32::unreachable(), the generated WASM contains two unreachable instructions instead of only one.

Example:

pub fn main(){
    core::arch::wasm32::unreachable();
}

Output (from Godbolt):

example::main:
        unreachable
        unreachable
        end_function

Godbolt link: https://rust.godbolt.org/z/Yqz6Kh9eq

This is mostly noticeable when using build-std-features=panic_immediate_abort (which I know is unstable), as all instances of panic!() are basically replaced with unreachable(), and then compile down to two unreachable instructions.

This behavior appears to have been present since core::arch::wasm32::unreachable() was made available, so this is not a regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions