Skip to content

Stage 2 llvm backend, improve code gen for return values #9581

@lerno

Description

@lerno

Currently the ABI for passing optional and error parameters prevent full optimization by LLVM.

  1. Sub optimal code generation with full optimization when using catch |...|
    https://godbolt.org/z/xqTKWKW37

  2. Optimal code generation with full optimization when performing essentially the same but using catch 1
    https://godbolt.org/z/PWe4GPb3c

For Optional, both variants produce sub optimal code:
https://godbolt.org/z/qGavK9aWK

Note that Swift has a similar strategy (passing a struct), but manages to get better optimization:
https://godbolt.org/z/4xa5Y85Gx

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmThe LLVM backend outputs an LLVM IR Module.enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.optimization

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions