<div dir="ltr">FWIW, I already have patches ready. I'll clean 'em up and post if you want to run the RFC and maybe propose documentation updates?</div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 16, 2018 at 4:58 PM Davide Italiano <<a href="mailto:davide@freebsd.org">davide@freebsd.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Dec 15, 2018 at 9:37 PM Chandler Carruth <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>> wrote:<br>
><br>
> On Sat, Dec 15, 2018 at 6:13 PM Davide Italiano <<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>> wrote:<br>
>><br>
>> On Sat, Dec 15, 2018 at 12:02 PM Vedant Kumar via llvm-dev<br>
>> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> ><br>
>> > Hi,<br>
>> ><br>
>> > > On Dec 15, 2018, at 10:32 AM, Brian Gesiak via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> > ><br>
>> > > Hello all!<br>
>> > ><br>
>> > > I find that using lldb to debug LLVM libraries can be super<br>
>> > > frustrating, because a lot of LLVM classes, like the constructor for<br>
>> > > StringRef, are marked LLVM_ATTRIBUTE_ALWAYS_INLINE. So when I attempt<br>
>> > > to have lldb evaluate an expression that implicitly instantiates a<br>
>> > > StringRef, I get 'error: Couldn't lookup symbols:<br>
>> > > __ZN4llvm9StringRefC1EPKc'.<br>
>> > ><br>
>> > > As an example, most recently this happened to me when playing around<br>
>> > > with llvm::AttributeSet, having attached lldb to an opt built with<br>
>> > > -DCMAKE_BUILD_TYPE="Debug":<br>
>> > ><br>
>> > > (lldb) e $AS.hasAttribute("myattr")<br>
>> > > error: Couldn't lookup symbols:<br>
>> > > __ZN4llvm9StringRefC1EPKc<br>
>> > ><br>
>> > > Despite having built in a "Debug" configuration,<br>
>> > > LLVM_ATTRIBUTE_ALWAYS_INLINE makes it very difficult to debug LLVM.<br>
>> > ><br>
>> > > How do you all deal with or work around this problem?<br>
>> ><br>
>> > I don't think there are any great workarounds. The data formatters in utils/lldbDataFormatters.py can help a bit.<br>
>> ><br>
>> ><br>
>> > > Is there a good<br>
>> > > way to do so? If not, would anyone object if I sent up a patch to<br>
>> > > introduce a CMake variable or something to conditionally disable<br>
>> > > LLVM_ATTRIBUTE_ALWAYS_INLINE? I'd like to be able to turn it off, but<br>
>> > > I'm not sure if there's some good reason it needs to stay on even for<br>
>> > > debug builds?<br>
>> ><br>
>> > IIRC the motivation for using always_inline in debug builds was to make binaries acceptably fast. IMHO this isn't the right tradeoff because it also makes binaries frustratingly hard to debug.<br>
>> ><br>
>> > Some might object that with clang modules, it should be no trouble for a debugger to evaluate these kinds of expressions. I've CC'd Raphael who can speak to this much better than I can. My understanding is that modules may help, but lldb (and presumably gdb as well?) are not going to learn how to parse templated code out of C++ modules, instantiate them, and JIT-compile them for you really soon. That seems like an ongoing, longer-term project.<br>
>> ><br>
>> > I'd like to see us move away from using always_inline in core ADT headers to make debugging easier in the near future.<br>
>> ><br>
>><br>
>> +1 to everything you said. I happened to remember this wasn't always<br>
>> the case for StringRef, so I did some archeology and found:<br>
>> [llvm] r247253 - [ADT] Apply a large hammer to StringRef functions:<br>
>> attribute always_inline.<br>
>><br>
>> I'm afraid I missed the commit at the time but there are few remarks I<br>
>> would like to make:<br>
>> 1) The motivation for this change, at least from what I understand, is<br>
>> trying to optimize `check-llvm`. As somebody who spends a fair amount<br>
>> of time tapping fingers while waiting for the tests to run, I do<br>
>> believe this is a laudable goal, but I'm uncertain of the results. In<br>
>> fact, it seems it only saves 1 second (according to the commit<br>
>> message).<br>
><br>
><br>
> There were a string of related commits here, not just one. They added up at the time.<br>
><br>
>><br>
>> 2) I can't speak for anybody else, but I'm not entirely sure a<br>
>> 48-cores box is a common setup (I might be completely wrong on this<br>
>> one, but I have [and had] access to much more modest hardware). In<br>
>> other words, I'm not entirely sure the setup that drove the change is<br>
>> representative of the "typical" llvm developer (for some definition of<br>
>><br>
>> "typical").<br>
><br>
><br>
> Not sure this is terribly relevant.... if anything, it minimizes the total impact. Anyways....<br>
><br>
>> 3) I think the tradeoff here is just not great. I personally devote<br>
>> much more time debugging llvm (and related subprojects) than running<br>
>> the testsuite.<br>
><br>
><br>
> s/testsuite/check-llvm<br>
><br>
> But this I disagree with, FWIW. Anyways, not sure it is relevant anymore...<br>
><br>
>> Chandler, is there anything that can be done here to make the<br>
>> experience less frustrating (i.e. revising the decision or reverting)?<br>
>> The original commit pointed out this was a workaround, but the status<br>
>> quo is that it makes debugging llvm itself much harder.<br>
>> Of course, happy to help.<br>
><br>
><br>
> I think the time where this made sense has passed us by, and I'm happy to systematically rip all these things out.<br>
><br>
> These days, I do not think there is any reasonable performance of `check-llvm` (or any other `check-foo` w/o optimizations enabled, and debug info disabled. The former is necessary to get plausible test times, and the latter is (sadly) necessary to get plausible build times. As a consequence, I exclusively use optimized (but w/ asserts) builds for running `check-foo`, and do a separate build if I ever need to debug something. So I no longer see any benefit from these always-inline attributes, and only the down sides. I suspect this is true for most developers these days: they are all downside. If the developer cares about check-foo, they use an optimized build.<br>
><br>
> So, as long as we are prepared to add specific guidance to our documentation that folks hacking on LLVM (and subprojects) should generally expect to enable -O2 at least to see reasonable test performance, I'm happy to rip out all the always inline in the whole thing. Even happy to do the work. Just need the community to agree about the direction.<br>
<br>
Sounds like we have a plan then. I'm happy to volunteer. I guess we<br>
just need to wait some time to see if people have objections, and then<br>
send an RFC to the mailing list once the patches are ready.<br>
<br>
Thanks for your time.<br>
<br>
-- <br>
Davide<br>
<br>
"There are no solved problems; there are only problems that are more<br>
or less solved" -- Henri Poincare<br>
</blockquote></div>