Open Quuxplusone opened 9 years ago
Bugzilla Link | PR23874 |
Status | NEW |
Importance | P normal |
Reported by | Derek Schuff (dschuff@google.com) |
Reported on | 2015-06-17 13:30:51 -0700 |
Last modified on | 2015-06-18 16:00:30 -0700 |
Version | trunk |
Hardware | PC Linux |
CC | dblaikie@gmail.com, dexonsmith@apple.com, echristo@gmail.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com, rafael@espindo.la |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | PR23367 |
See also |
File is too bug to upload. get it at https://drive.google.com/file/d/0B_T-_5p_VNCtMmYwZG90eWpWU0k/view?usp=sharing
Derek - you describe the module verifier visiting the DISubprogram for the middle function. Yet you described the middle function as not having debug info. What's the deal there?
(In reply to comment #0)
I have attached a reproducer which is reduced by bugpoint; bugpoint did a pretty good job reducing the code but did nothing to the debug info, which is still huge, so I'm looking for some suggestions for making that smaller. I tried removing the !llvm.dbg.cu from the module; this had mostly the effect I was looking for, in causing most of the metadata to go away, but it also caused the problem to no longer reproduce.
Any suggestions?
Here's the rough algorithm I use.
This is often good enough. But if I really just have bitcode (e.g., from a crash in a huge LTO) or the repro is still large, I continue:
subprograms:
array, bisect which ones are necessary.(Any time you make progress, you can round-trip to bitcode to garbage collect unreferenced metadata.)
another tip, once auto-reduction has stopped (& you've done all the obvious things that auto-reduction can't do - stripping templates and the like is one of the big ones creduce is still not very good at) you can try using alwaysinline attributes to force the inlining that the optimizer is doing anyway - then you can sometimes get back to an -O0 reproduction, jsut forcing the problematic inlining explicitly that way
Thanks for the tips. The actual functions are reasonably well reduced, i'll try bisecting down the CUs and see what I can come up with. If that fails i'll go back to the source.
@David: When the inner function gets inlined into middle, its instructions keep their debug info.
There shouldn't be a DISubprogram for 'middle' then - so I'm not sure what the Verifier's visiting.
Perhaps it visited the instructions of 'middle' even though there was no DISubprogram - then compared the Function on the DISubprogram it reached from the instructions' debuglocs to the function the instructions were in and failed? That would be a bug in the verifier - it shouldn't inspect functions without DISubprograms.
Hm, interesting. in my repro there is a DISubprogram for the middle function, but the function itself has no dbg attachments. Maybe that is the underlying unexpected thing?
(In reply to comment #7)
> Hm, interesting. in my repro there is a DISubprogram for the middle
> function, but the function itself has no dbg attachments. Maybe that is the
> underlying unexpected thing?
Yes, that's likely to be a bad thing. The current requirement is that the call
instruction must have a debug location if the caller and callee have debug info
and the call site is inlinable.
If that requirement is violated => badness.
If you can create a small test case where that happens, that'd be great.
This file is the result of a bitcode link of some files which have debug info (libc++) and some which do not (all the user files).
I'll try to see if the invariant you mentioned is getting violated in that process. It's also possible that one of the passes we run is dropping something it shouldn't.
In my linked bitcode file, there are some calls to middle which have dbg
attachments (in this case from libgtest, which is built with debug info), and
some calls which do not (other user files built without debug info).
Middle is a comdat function, and the one included in the link output has no dbg
attachments (presumably the copies from those files that were built with debug
info had the attachments). There is also a DISubprogram for middle. I guess if
the callee (middle) has no dbg attachements it should not have a DISubprogram?
I guess I should look at the behavior of the linker in that case?
Ah, that does sound like it could be an LTO bug:
Build one object (bitcode) file without debug info
Build one object (bitcode) file with debug info.
Have the same comdat function in both.
Choose the non-debug-having implementation of the function, while keeping the
subprogram debug info from the debug-having implementation.
Duncan, does that sound like a thing that can/would happen?
Once we put subprogram debug info as a function metadata attachment, would that
fix this bug?
(In reply to comment #11)
> Ah, that does sound like it could be an LTO bug:
>
> Build one object (bitcode) file without debug info
> Build one object (bitcode) file with debug info.
>
> Have the same comdat function in both.
>
> Choose the non-debug-having implementation of the function, while keeping
> the subprogram debug info from the debug-having implementation.
>
> Duncan, does that sound like a thing that can/would happen?
Yes, that sounds possible.
> Once we put subprogram debug info as a function metadata attachment, would
> that fix this bug?
Yes, I think so. That's tracked by bug 23367, which I'm hoping to get back to
soon (along with a bunch of follow-ups).