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

Nikolay Panchenko via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 15:24:59 PDT 2024


npanchen wrote:

> If we had an explicit initialization of all subtargets / TargetOptions needed by a module, and made the contexts external (i.e. #111234),

If by "explicit initialization" you refer to calling `getSubtargetImpl`, this won't be sufficient, unfortunately. Having something like `TargetMachine::setSubtarget(shared_ptr<TargetSubtargetInfo>)` might help.

>  can you just use the one TargetMachine? Other than those, the TargetMachine should be stateless

To describe the problem a bit more: there's parallel compilation that use identical TargetMachines, but different instances. it's known that at some point `TargetSubtargetInfo` can be released to reduce memory footprint.  Ideally, if TargetMachine is stateless, there will be no need to have different instances.

if you or @topperc can recommend what can be done in a short term, that will be great. 

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


More information about the llvm-commits mailing list