Skip to content
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

Fix debug location for ~check_proc_is_not_closure #11311

Merged

Conversation

HertzDevil
Copy link
Contributor

When passing a closure to a lib fun and the compiler cannot figure this out, the program calls ~check_proc_is_not_closure to raise an exception. This generated LLVM function has a proper debug location, but the inner raise call doesn't, and is still attached to the beginning of the source file:

Screenshot_20211014_073235

Here the filtered assembly output on Compiler Explorer shows the isolated raise call because of this. This PR fixes that.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:debugger labels Oct 13, 2021
@asterite
Copy link
Member

Could we maybe change the location of the call (maybe not caching it, or changing it on every use) so it points to the correct location? That said, I'm not sure what would be better this way.

@HertzDevil
Copy link
Contributor Author

That would probably be the same as inlining ~check_proc_is_not_closure in every place that needs it (passing Procs to lib funs, as well as assigning Procs to members of lib or extern structs).

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

This patch looks good. If we can make it even better, I'm all in.

@straight-shoota straight-shoota added this to the 1.3.0 milestone Nov 14, 2021
@straight-shoota straight-shoota merged commit c6bdae6 into crystal-lang:master Nov 16, 2021
@HertzDevil HertzDevil deleted the bug/pass-closure-to-c-debug-loc branch November 17, 2021 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:debugger
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants