[llvm-dev] Debuggability of -O1 level

Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 5 11:46:50 PST 2018


> On Feb 5, 2018, at 2:39 AM, Son Tuan VU <sontuan.vu119 at gmail.com> wrote:
> 
> Hello Paul, François and Vedant,
> 
> Thank you all for your answers. And sorry for this late reply. I wanted to dig more into the LLVM source code to get a better understanding of the debug part of it before replying/asking more questions.
> 
> I have came across this https://llvm.org/docs/SourceLevelDebugging.html#debugging-optimized-code <https://llvm.org/docs/SourceLevelDebugging.html#debugging-optimized-code> which stated that 
> "Basically, the debug information allows you to compile a program with “-O0 -g” and get full debug information, allowing you to arbitrarily modify the program as it executes from a debugger. Compiling a program with “-O3 -g” gives you full debug information that is always available and accurate for reading (e.g., you get accurate stack traces despite tail call elimination and inlining), but you might lose the ability to modify the program and call functions which were optimized out of the program, or inlined away completely."
> 
> Does it really mean that I can find out the location expressions of *every* variable / function in the source program (of course if it is not removed by the compiler), even at "-O3 -g"?
> 
> @Vedant: I have tried your debugify utility, thanks for the great tool! However, currently, debugify assumes the not-so-exact line number for the debugging entities (code statements, variables, functions). Is it expected?

Debugify numbers each instruction in a Module from 1..N in the order they are visited. The idea is that when a location is dropped, it's simple to find the hole in the range. Could you clarify what you meant by non-so-exact line numbers?

best,
vedant

> 
> @Paul: Thanks a lot for your very informative summary. I wonder how I can help with the project though, do you have any concrete task that needs to be implemented, or do you mean a GSoC project?
> 
> Cheers,
> 
> 
> Son Tuan Vu
> 
> On Mon, Jan 29, 2018 at 11:08 PM, Vedant Kumar <vsk at apple.com <mailto:vsk at apple.com>> wrote:
> Hi,
> 
> I'm not sure which passes exactly drop debug info, but it's likely that most of them do. If you're interested in working on this problem, I suggest experimenting with the debugify utility in opt. This tool can be used to identify passes which drop debug info and to generate targeted/reduced test cases for specific problems. To use it, you can add the '-enable-debugify' flag to opt's list of arguments. E.g:
> 
>   opt < ~/src/llvm/test/Transforms/InstCombine/icmp-div-constant.ll -instcombine -S -enable-debugify
> 
> If you're interested in collecting statistics on which passes drop the most debug info, you could teach the debugify pass to log the number of dropped variables/locations per test, and run the test suite with `llvm-lit -Dopt="opt -enable-debugify"`. It would be really useful to have that information.
> 
> best,
> vedant
> 
> 
> > On Jan 29, 2018, at 12:45 PM, Francois Pichet via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> >
> > My experience is that just running mem2reg (while disabling virtually all other passes ) in O1 will substantially improve debuggability while giving acceptable performance.
> >
> > On Mon, Jan 29, 2018 at 11:39 AM, via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> > (Remembering to +llvm-dev this time…)
> >
> >
> >
> > There has been some progress in the direction of improving debuggability of optimized code, in the past year.  There have been a number of patches to improve tracking of debug info in various passes, and some more general improvements such as work on the LiveDebugValues pass.  I don't think anyone has done a specific analysis to identify passes that lose debug info.
> >
> > However, various people/teams have an interest in making improvements here, and continue to devote some resources to the longer term project.  For example there is the Extend Lifetimes work described by Wolfgang Pieb at the 2017 LLVM Developers Meeting.  We have also looked into how the instruction scheduler might be interfering with the debugging experience.
> >
> > Part of the problem is that the "debugging experience" is a fairly qualitative thing, but in order to attack the problem properly we need a more analytic quantitative measure of how we are doing, which will hopefully lead us to areas where things can improve.  See for example the DIVA tool, described at the 2017 EuroLLVM.  Sony also has some other internal tools, which I hope we can describe at future meetings and make available to the community.
> >
> >
> >
> > In short, there is continued interest and (more importantly) effort towards both –Og in particular and improving the debugging of optimized code in general.  I am hopeful that we can eventually reach a point where we can define an –Og that is as debuggable as –O0 while still having distinctly better runtime performance.  Whether –Og becomes its own thing, or ends up as a redefinition of –O1, remains to be decided.
> >
> >
> >
> > Thanks for your interest, and giving me a reason to write up this little summary.  And if you are motivated to help with the project, that's great!
> >
> > --paulr
> >
> >
> >
> >
> >
> >
> >
> > From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org <mailto:llvm-dev-bounces at lists.llvm.org>] On Behalf Of Son Tuan VU via llvm-dev
> > Sent: Monday, January 29, 2018 7:35 AM
> > To: llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> > Subject: [llvm-dev] Debuggability of -O1 level
> >
> >
> >
> > Hello all,
> >
> >
> >
> > I've found an old post (November 2016) http://lists.llvm.org/pipermail/llvm-dev/2016-November/107006.html <http://lists.llvm.org/pipermail/llvm-dev/2016-November/107006.html> which discussed debug information for optimized code. At the end of that discussion, Adrian broached the interest in making -O1 only enable optimizations. I see in the code (clang/lib/Frontend/CompilerInvocation.cpp, in function getOptimizationLevel) that -Og option is equivalent to -O1. Does this mean any progress on making -O1 the GCC's -Og? If not, would someone kindly tell me what is holding the debuggability at -O1 back? Which optimization passes are removing our debug info at this -O1 level?
> >
> >
> >
> > Thank you for your help,
> >
> >
> >
> > Son Tuan Vu
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180205/ec798894/attachment.html>


More information about the llvm-dev mailing list