[llvm-dev] Deleting function IR after codegen
Pete Cooper via llvm-dev
llvm-dev at lists.llvm.org
Mon Mar 7 17:24:33 PST 2016
> On Mar 7, 2016, at 4:56 PM, Hal Finkel <hfinkel at anl.gov> wrote:
>
> ----- Original Message -----
>> From: "Pete Cooper" <peter_cooper at apple.com <mailto:peter_cooper at apple.com>>
>> To: "Chandler Carruth" <chandlerc at gmail.com <mailto:chandlerc at gmail.com>>, "Duncan P. N. Exon Smith" <dexonsmith at apple.com <mailto:dexonsmith at apple.com>>, "Hal Finkel"
>> <hfinkel at anl.gov <mailto:hfinkel at anl.gov>>, "Philip Reames" <listmail at philipreames.com <mailto:listmail at philipreames.com>>, "Mehdi Amini" <mehdi.amini at apple.com <mailto:mehdi.amini at apple.com>>, "Rafael
>> Espíndola" <rafael.espindola at gmail.com <mailto:rafael.espindola at gmail.com>>
>> Cc: "llvm-dev" <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>>
>> Sent: Monday, March 7, 2016 6:44:06 PM
>> Subject: Deleting function IR after codegen
>>
>> Hi all
>>
>> After codegen for a given function, the IR should no longer be
>> needed. In the AsmPrinter we convert from MI->MCInstr, and then we
>> never go back and look at the IR during the MC layer.
>>
>> I’ve prototyped a simple pass which can be (optionally) scheduled to
>> do just this. It is added at the end of addPassesToEmitFile. It is
>> optional so that clang can continue to leak the IR with
>> --disable-free, but i would propose that all other tools, and
>> especially LTO, would enable it. The savings are 20% of peak memory
>> in LTO of clang itself.
>>
>> I could attach a patch, but first i’d really like to know if anyone
>> is fundamentally opposed to this.
>>
>> I should note, a couple of issues have come up in the prototype.
>> - llvm::getDISubprogram was walking the function body to find the
>> subprogram. This is trivial to fix as functions now have !dbg on
>> them.
>> - The AsmPrinter is calling canBeOmittedFromSymbolTable on
>> GlobalValue’s which then walks all their uses. I think this should
>> be done earlier in codegen as an analysis whose results are
>> available to the AsmPrinter.
>
> I imagine that these are good cleanups regardless, it sounds like the fixes are also likely compile-time improvements.
Cool. I’ll get some patches together for these then. The first should be out soon.
And yes, the !dbg one in particular should be a small compile time improvement.
>
>> - BB’s whose addresses are taken, i.e. jump tables, can’t be deleted.
>> Those functions will just keep their IR around so no changes there.
>>
>> With the above issues fixed, I can run make check and pass all the
>> tests.
>>
>> Comments very welcome.
>
> As an optional feature, it certainly makes sense to me.
Thanks! :)
Pete
>
> -Hal
>
>>
>> Cheers,
>> Pete
>
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160307/0f0f36b6/attachment.html>
More information about the llvm-dev
mailing list