[llvm] [AArch64] Use GISel for optnone functions (PR #174746)
Ryan Cowan via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 17 01:22:04 PST 2026
================
@@ -387,12 +387,19 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT,
// for the tiny code model, the maximum TLS size is 1MiB (< 16MiB)
this->Options.TLSSize = 24;
- // Enable GlobalISel at or below EnableGlobalISelAt0, unless this is
- // MachO/CodeModel::Large, which GlobalISel does not support.
- if (static_cast<int>(getOptLevel()) <= EnableGlobalISelAtO &&
+ const bool TargetSupportsGISel =
TT.getArch() != Triple::aarch64_32 &&
TT.getEnvironment() != Triple::GNUILP32 &&
- !(getCodeModel() == CodeModel::Large && TT.isOSBinFormatMachO())) {
+ !(getCodeModel() == CodeModel::Large && TT.isOSBinFormatMachO());
+
+ const bool GlobalISelFlag =
+ getCGPassBuilderOption().EnableGlobalISelOption.value_or(false);
+
+ // Enable GlobalISel at or below EnableGlobalISelAt0, unless this is
+ // MachO/CodeModel::Large, which GlobalISel does not support.
+ if (TargetSupportsGISel &&
+ (static_cast<int>(getOptLevel()) <= EnableGlobalISelAtO ||
+ (!GlobalISelFlag && !Options.EnableGlobalISel))) {
----------------
HolyMolyCowMan wrote:
It was really quite tricky to get this logic to do what we wanted without exposing a point of control.
This comment roughly explains the idea behind the check.
```
// GlobalISel is currently only enabled when the opt level is less than or
// equal to EnableGlobalISelAt or it was explicitly enabled via the CLI. If we
// encounter this check, we know GlobalISel was enabled. If not by these two,
// it must have been used as part of the SDAG pipeline to use GlobalISel for
// optnone.
```
I used the absence of the GlobalISel flag & the EnableGlobalISel option to determine whether GlobalISel had been enabled purposefully, in which case we can avoid the SDAG pipeline or as part of a fallback from the SDAG pipeline. I would have preferred to add some kind of control we could use to explicitly alter this.
I do think that part of the rationale behind this work was to disable the use of fastisel at O0 but I'd want to check that.
I've had a look at your potential fix, it looks like it would work but I'm wondering why you check the optlevel isn't 0?
https://github.com/llvm/llvm-project/pull/174746
More information about the llvm-commits
mailing list