[PATCH] D115545: [Inline] Attempt to delete any discardable if unused functions

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 16 01:57:08 PST 2021


nikic added a comment.

In D115545#3196100 <https://reviews.llvm.org/D115545#3196100>, @aeubanks wrote:

> In D115545#3192006 <https://reviews.llvm.org/D115545#3192006>, @nikic wrote:
>
>> In D115545#3190357 <https://reviews.llvm.org/D115545#3190357>, @aeubanks wrote:
>>
>>> this causes compile time regressions due to calling LazyCallGraph::removeDeadFunction() more, seeing if that can be optimized
>>
>> That seems surprising, what's so expensive about that method?
>
> Weird, I remeasured and it didn't show up as significant anymore.
>
> Now `filterDeadComdatFunctions()` is extremely expensive, which makes sense since we're iterating over every function/global in the module on every inliner run on an SCC. Not sure there's a good way around this unless we start keeping track of comdat users within the comdat.

Keeping track of users makes sense to me, and doesn't seem overly complicated. I've put up a prototype at D115864 <https://reviews.llvm.org/D115864>.

> Shame since this saves a lot of memory of template heavy code: https://llvm-compile-time-tracker.com/compare.php?from=d66323c1ef28104ccf7d72e05954fc1241845a33&to=c0a6e811b81deee725a2eaf37662d7181e11e704&stat=max-rss. Which I actually don't really understand. I would have thought that we're already clearing function analyses due to the recently added eager invalidation flag, and I wouldn't think that the IR itself takes up that much memory compared to analyses, but maybe I'm wrong.

I believe we'd keep analyses queried on the callee (which should be BFI -> LI -> DT), as we'll only invalidate analysis on the caller after inlining is done. Which does seem like the right thing to do, otherwise we'd recompute those every time a callee is considered. But I also don't think these analyses are particularly large either.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115545/new/

https://reviews.llvm.org/D115545



More information about the llvm-commits mailing list