Skip to content

Add new llvm.dbg.coroframe_entry intrinsic and support for it in the Corosplitter pass #11245

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

Open
wants to merge 2 commits into
base: stable/21.x
Choose a base branch
from

Conversation

rastogishubham
Copy link

@rastogishubham rastogishubham commented Aug 22, 2025

For swift async debug info, we create llvm.dbg.declare that contain
locations which may not be a pointer or int. This is fine, because the
CoroSplitter pass fixes up those llvm.dbg.declares later.

However, with a recent change to the LLVM Verifier, there is a check
that asserts if there is a llvm.dbg.declare with a location other than
a pointer or an int.

To workaround the problem, we created a new llvm.dbg.coroframe_entry
intrinsic that doesn't have the same restrictions as llvm.dbg.declare, it
can take non pointer and integer location types.

We also need to update the Corosplitter pass to correctly handle the
new llvm.dbg.coroframe_entry intrinsic, while making sure that it is
converted to a llvm.dbg.declare after the CoroSplitter has run, so that
subsequent passes do not have to be updated to handle the
llvm.dbg.coroframe_entry intrinsic.

This patch achieves both of the above goals.

rdar://157299589

rdar://157509307

@rastogishubham rastogishubham changed the title Add dbg_coro as new DbgVariableRecord. Add #dbg_coroframe_entry as new DbgVariableRecord. Aug 22, 2025
@rastogishubham rastogishubham changed the title Add #dbg_coroframe_entry as new DbgVariableRecord. Add new llvm.dbg.coroframe_entry intrinsic. Aug 22, 2025
@rastogishubham rastogishubham changed the title Add new llvm.dbg.coroframe_entry intrinsic. Add new llvm.dbg.coroframe_entry intrinsic and support for it in the Corosplitter pass Aug 22, 2025
@rastogishubham rastogishubham marked this pull request as ready for review August 22, 2025 22:03
@rastogishubham rastogishubham force-pushed the AddDbgCoro branch 2 times, most recently from 3f4004b to 2d3a5cb Compare August 22, 2025 22:16
LLVM_ABI TinyPtrVector<DbgCoroFrameEntryInst *>
findDbgCoroFrameEntrys(Value *V);
/// As above, for DVRCoroFrameEntrys.
LLVM_ABI TinyPtrVector<DbgVariableRecord *> findDVRCoroFrameEntrys(Value *V);

Choose a reason for hiding this comment

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

We should (upstream) replace this with one API that lets you pass a kind parameter.

Copy link
Author

Choose a reason for hiding this comment

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

I added a FIXME comment

Copy link

@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 also put some placeholder comments into LangRef so we don't forget to update that when upstreaming?

@rastogishubham rastogishubham force-pushed the AddDbgCoro branch 3 times, most recently from 0055330 to b09a8ac Compare August 22, 2025 22:46
For swift async code, we need to use a debug intrinsic that behaves like
an llvm.dbg.declare but can take any location type rather than just a
pointer or integer.

To solve this, a new debug instrinsic called llvm.dbg.coroframe_entry
has been created, which behaves exactly like an llvm.dbg.declare but
can take non pointer and integer location types.

rdar://157299589

rdar://157509307
Make sure the CoroSplitter pass correctly handles
llvm.dbg.coroframe_entry intrinsics. Also, convert them to
llvm.dbg.declares so that any subsquent passes do not need to be amended
to support the llvm.dbg.coroframe_entry intrinsic.

rdar://157299589

rdar://157509307
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.

2 participants