GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tail call codegen for error returns · Issue #690 · ziglang/zig

tail call codegen for error returns #690

New issue
Copy link
New issue
Copy link
Open
Open
tail call codegen for error returns#690
Copy link
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.optimization
Milestone
urgent

Description

@andrewrk
andrewrk
opened on Jan 15, 2018
Issue body actions

for error unions it looks like this:

  tail call fastcc void @__zig_return_error(%StackTrace* %0, i8* blockaddress(@foo, %ReturnError)), !dbg !50
  ret i16 %6, !dbg !50

We could have __zig_return_error take the sret parameter and populate the error value, then return void, so that it can be a tail call.

for pure errors we can pass the error code and return it, and then return it in the parent, another tail call.

Then look at the generated assembly and make sure we're doing tail calls. This is to keep the size of the code generated small for error return tracing. What is a return statement in code without error return tracing can become a jump instruction in code with error return tracing.

Reacted by Takeshi Yoneda, snjågloe, lin72h, Samuel Guyah and Max Milton

Activity

  1. andrewrk
    added
    optimization
    on Jan 15, 2018
  2. andrewrk
    added this to the 0.3.0 milestone on Jan 15, 2018
  3. andrewrk
    modified the milestones: 0.3.0, 0.4.0 on Feb 28, 2018
  4. andrewrk
    modified the milestones: 0.4.0, 0.5.0 on Feb 7, 2019
  5. andrewrk
    modified the milestones: 0.5.0, 0.6.0 on Sep 11, 2019
  6. andrewrk
    modified the milestones: 0.6.0, 0.7.0 on Oct 17, 2019
  7. luser commented on Mar 27, 2020

    @luser
    luser
    on Mar 27, 2020
    More actions

    Perhaps you've already seen it, but Swift's ABI dedicates a register to error return values:
    https://github.com/apple/swift/blob/master/docs/ABIStabilityManifesto.md#error-register
    https://github.com/apple/swift/blob/master/docs/ABI/RegisterUsage.md

    LLVM has a swifterror attribute to support this.

  8. andrewrk
    modified the milestones: 0.7.0, 0.8.0 on Oct 9, 2020
  9. andrewrk
    added
    frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
    on Oct 9, 2020
  10. SpexGuy
    added
    enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.
    on Feb 12, 2021
  11. andrewrk
    modified the milestones: 0.8.0, 0.9.0 on Jun 4, 2021
  12. andrewrk
    modified the milestones: 0.9.0, 0.10.0 on Nov 21, 2021
  13. andrewrk
    modified the milestones: 0.10.0, 0.11.0 on Apr 17, 2022
  14. perillo commented on Feb 12, 2023

    @perillo
    perillo
    on Feb 12, 2023
    Contributor
    More actions

    Is __zig_return_error used in stage2?

  15. Vexu commented on Feb 12, 2023

    @Vexu
    Vexu
    on Feb 12, 2023
    Member
    More actions

    Self hosted uses std.builtin.returnError.

  16. perillo commented on Feb 14, 2023

    @perillo
    perillo
    on Feb 14, 2023
    Contributor
    More actions

    Self hosted uses std.builtin.returnError.

    Thanks.

    I'm curious about the reason why an implementation detail is exposed in the standard library, and the reason why the function addErrRetTraceAddr is also public.

  17. andrewrk
    modified the milestones: 0.11.0, 0.12.0 on Apr 9, 2023
  18. mlugg
    added this to Safetyon Aug 22, 2024
  19. mlugg
    moved this to To do in Safetyon Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.optimization

    Type

    No type

    Projects

    • Safety
      Status
      To do
      Show more project fields

    Milestone

    • urgentNo due date

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.