Skip to content

[DebugInfo] Dont generate info for __swift_async_resume_project_conte… #75553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

felipepiovezan
Copy link
Contributor

@felipepiovezan felipepiovezan commented Jul 29, 2024

…xt or __swift_async_resume_get_context

These functions just return their own parameter and are inlined. We don't want to see any debug information nor inlined frames for these when looking at async backtraces.

Not only is it a bad user experience, but these inlined frames are involved in tail calls in virtual backtraces, which thoroughly confuse the debugger.

@felipepiovezan
Copy link
Contributor Author

Requires swiftlang/llvm-project#9025

@@ -2603,7 +2603,7 @@ llvm::Function *IRGenFunction::getOrCreateResumePrjFn(bool forPrologue) {
auto callerContext = IGF.emitAsyncResumeProjectContext(addr);
Builder.CreateRet(callerContext);
},
false /*isNoInline*/, forPrologue));
false /*isNoInline*/, true/*for prologue*/));
Copy link
Contributor

@jasonmolenda jasonmolenda Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the forPrologue parameter from getOrCreateResumePrjFn?

Copy link
Contributor Author

@felipepiovezan felipepiovezan Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't, because this function is used in a ton of places, most of them with "for prologue" == false.

What it would be nice is to rename this parameter to something more meaningful like "skip debug info", since this is what this parameter does. The original patch mixed the motivation from call sites with the effect inside this function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I missed that this could be called for one of two async resume functions, and it uses forPrologue to pick the name.

Copy link
Contributor

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this, so it's more obvious what changes?

…xt or __swift_async_resume_get_context

These functions are alwaysinline and their instructions are created with line 0
as a location. As a result, the instructions all get inlined with line 0 into
funclets. In practice, this makes it so that the first instruction of the
funclet containing a debug location happens much later. This is important
because the inlined instructions do meaningful work, like overwriting the
contents of `fp - 8`.

If we try to set a breakpoint into this funclet, we *must* break before these
instructions, by allowing the line 0 locations to propagate, we fail to do.

This patch changes this by removing all debug locations from the helper
functions. By doing so, when they are inlined, instructions will inherit the
location of the call site.
@felipepiovezan felipepiovezan force-pushed the felipe/unwinding_pc_patches_swift branch from f333324 to 768f391 Compare July 31, 2024 17:46
@felipepiovezan
Copy link
Contributor Author

Superseded by #75881

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants