[llvm] [Backend] Add clearSubtargetMap API for TargetMachine. (PR #112383)

weiwei chen via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 20:43:11 PDT 2024


weiweichen wrote:

> > > I mean the lazy construction of subtargets is an issue.
> > 
> > 
> > I don't think lazy construction itself is an issue here: regardless if it's lazy or not, multiple instance of a target machine is going to keep subtargets alive, thus memory footprint is going to stay high for longer than needed.
> 
> It would be for parallelization. What I am advocating for is making it so you can do parallel compilations with a single TargetMachine instance, not one per thread.
> 
> Is the memory footprint of subtargets really so large? I thought they were pretty tiny

They were pretty tiny by themselves (~4M for example), but they accumulate/multiply when there are many parallel tasks (for higher-level of parallelization) and we need a barrier to collect the codegen result together before doing the final AsmPrint. We see about 60% peak memory reduce if we can release these SubtargetInfos earlier and replace them with a shared copy.

https://github.com/llvm/llvm-project/pull/112383


More information about the llvm-commits mailing list