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

weiwei chen via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 11:47:27 PDT 2024


weiweichen wrote:

> If we had an explicit initialization of all subtargets / TargetOptions needed by a module, and made the contexts external (i.e. #111234), can you just use the one TargetMachine? Other than those, the TargetMachine should be stateless

Yes, it would solve the problem if the initialization can be don explicitly once and the `TargetMachine` is stateless. Thank for pointing me to the PR! I'll take a detailed look at the it. Though one thing I notice that the PR is not changing the [`mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap;`](https://github.com/llvm/llvm-project/pull/111234/files#diff-f7cbbcee7ebd578cd6b1a442bfe7ec533385b783deb2dc4e964adfdb5ca2eed5R27) private/protected member in concrete TargetMachines for different backends. They are `mutable` and being modified mostly in the same pattern [here](https://github.com/llvm/llvm-project/blob/b0a25468faca32d9db4d35e56fb120ed4eaeec09/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp#L467). Is there a plan to change that to make TargetMachine fully stateless as well?



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


More information about the llvm-commits mailing list