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

Loss of debug information with optimization and inlining #2375

Open
Sahnvour opened this issue Apr 28, 2019 · 1 comment
Open

Loss of debug information with optimization and inlining #2375

Sahnvour opened this issue Apr 28, 2019 · 1 comment
Labels
os-windows upstream An issue with a third party project that Zig uses.
Milestone

Comments

@Sahnvour
Copy link
Contributor

I have identified cases where an inlined function's instructions all end up with their debug information pointing to an invalid source.

In particular, I have a program calling a function foo that itself calls bar. bar is inlined when it is called by foo, but the PDB matches all the instructions produced by bar with the definition line of foo. Even though bar is non-trivial and should clearly be identifiable, even in optimized code. Indeed, this is a problem in Release mode.

I think this may have gone unnoticed because we usually don't use debug info much with release executables. I encountered this when trying to profile my program, and saw that every sampled instruction was matched with the function definition. The same happens when running it through a debugger.

Modifying foo to do @noInlineCall(bar, ...) fixed this and I was then able to step through bar.

@andrewrk I think this is related to the issue we discussed in #2029. Which now makes me wonder if it's a target-specific issue.

I stepped through the ir_render and ir_render_call in case I find anything suspicious, but at this point the debug info seemed correct. Maybe the issue occurs later, in a LLVM optimization pass, when instructions are merged and the wrong debug info is chosen ? For example, since in my case everything bar does is related to its parameters (themselves coming from foo), it could be that somehow the debug info from parameter declarations are kept. Just a supposition, I don't know much about LLVM.

@andrewrk andrewrk added upstream An issue with a third party project that Zig uses. os-windows labels Apr 29, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Apr 29, 2019
@andrewrk
Copy link
Member

I think the next step in this issue is to come up with a small zig test case, followed by a pure LLVM IR test case, and then filing an upstream bug report.

@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Oct 17, 2019
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 30, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os-windows upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

No branches or pull requests

2 participants