[llvm] [AArch64] Cache repeated subtarget queries (NFC) (PR #222637)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 01:54:25 PDT 2026


================
@@ -436,6 +439,12 @@ AArch64TargetMachine::~AArch64TargetMachine() = default;
 
 const AArch64Subtarget *
 AArch64TargetMachine::getSubtargetImpl(const Function &F) const {
+  // Constructing the subtarget key is not cheap, avoid rebuilding it for
+  // repeated queries with the same function attributes.
+  AttributeSet FnAttrs = F.getAttributes().getFnAttrs();
+  if (LastSubtarget && LastSubtargetAttrs == FnAttrs)
----------------
sdesmalen-arm wrote:

It's a bit niche, but I see there is some other state as well (`ForceStreaming`, `ForceStreamingCompatible`, `SVEVectorBitsMin/MaxOpt`), which are currently not included in the check for state. Could this introduce unexpected behaviour for the tests?

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


More information about the llvm-commits mailing list