[llvm-dev] Saving Compile Time in InstCombine
Daniel Berlin via llvm-dev
llvm-dev at lists.llvm.org
Sat Apr 15 12:29:41 PDT 2017
On Sat, Apr 15, 2017 at 11:53 AM, Chris Lattner <clattner at nondot.org> wrote:
> On Apr 13, 2017, at 8:27 PM, Daniel Berlin via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
> Out of 35% InstCombine time, about half is spent in the top 5 visitor
> routines.
>
>>
>> I wanted to see what transformations InstCombine actually performs. Using
>> -debug option turned out not to be very scalable. Never mind the large
>> output size of the trace, running "opt -debug -instcombineā€¯
>
>
> on anything other than a small IR is excruciatingly slow. Out of curiosity
>> I profiled it too: 96% of the time is spent decoding and printing
>> instructions. Is this a known problem?
>
>
> Yes
>
> The problem is *every* value print call builds an assembly writer, which
> calls the module typefinder to be able to print the types. This walks
> everything in the module to find the types.
> For large ir with a lot of types, this is *ridiculously* slow.
>
> IE it's basically processing a large part of the module for *every
> operand* it prints.
>
> You can, for something like what you are doing, just hack it up to build
> it once or not at all.
>
> I've never understood why this doesn't annoy people more :)
>
> As a hack, you can comment out AsmWriter.cpp:2137
>
>
> You can just create a ModuleSlotTracker and pass it back into the print
> functions.
>
It's not the slot tracker (which does not waste any time, AFAICT), it's the
type incorporation of the typeprinter, which walks the entire module, and
is getting recreated on every single operator << call.
But yes, you could create a typeprinter and pass it back in (if typeprinter
wasn't internal to AsmWriter.cpp).
But then every operator << you use has to be passed a typeprinter or be
super slow. That also seems silly, because most people want to do
DEBUG(dbgs() << "This instruction: " << *I << " did a thing\n");
and trying to keep and pass a type printer into all of these, ...
alternatively, rewriting them also sucks.
This is in fact, why nobody does it. Because they just want the above to
work and not worry about the fact that deep down, we are wasting tremendous
amounts of time.
> -Chris
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170415/0af58088/attachment.html>
More information about the llvm-dev
mailing list