Skip to content

noreturn functions save registersΒ #23952

@Uthedris

Description

@Uthedris

Zig Version

0.15.0-dev.558+9279ff888

Steps to Reproduce and Observed Behavior

Compile a function with a return type of noreturn. The generated code saves various registers.

Tested on compiler for rp2350 arm and riscv.

Expected Behavior

noreturn functions should not save registers.

Since the function cannot return, there is no reason to save existing registers, so doing so just wastes stack space. This is especially a problem when writing code for small embedded processors or other situation where stack space is at a premium.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmThe LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behavioroptimizationupstreamAn issue with a third party project that Zig uses.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions