Repository navigation
[TTI][Inline] Define inlining behavior in SubtargetFeature - #205348
Conversation
This allows specifying the InliningBehavior as part of SubtargetFeature. The behavior is one of InlineDefault, InlineInverse, and InlineIgnore. * InlineDefault: Caller can have more features than callee. * InlineInverse: Caller can have less features than callee. * InlineIgnore: Caller can have more or less features than callee. The default areInlineCompatible() implementation respects these now. The intention behind this change is that it reduces the risk of forgetting to update feature lists in TTI when adding a new feature, e.g. when adding a new tuning flag that should be InlineIgnore. Move X86 and AMDGPU ignored features, and the one inverse feature on AArch64 to TableGen. There is various followup work to do here, e.g. currently tuning flags on AArch64 are not ignored (and on AMDGPU only some are ignored).
|
@llvm/pr-subscribers-tablegen @llvm/pr-subscribers-backend-aarch64 Author: Nikita Popov (nikic) ChangesThis allows specifying the InliningBehavior as part of SubtargetFeature. The behavior is one of InlineDefault, InlineInverse, and InlineIgnore.
The default areInlineCompatible() implementation respects these now. The intention behind this change is that it reduces the risk of forgetting to update feature lists in TTI when adding a new feature, e.g. when adding a new tuning flag that should be InlineIgnore. Move X86 and AMDGPU ignored features, and the one inverse feature on AArch64 to TableGen. There is various followup work to do here, e.g. currently tuning flags on AArch64 are not ignored (and on AMDGPU only some are ignored). Patch is 53.03 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/205348.diff 14 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index d64cda740a77f..8c4df6664cf1d 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -397,10 +397,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
const Function *Callee) const override {
const TargetMachine &TM = getTLI()->getTargetMachine();
- const FeatureBitset &CallerBits =
- TM.getSubtargetImpl(*Caller)->getFeatureBits();
- const FeatureBitset &CalleeBits =
- TM.getSubtargetImpl(*Callee)->getFeatureBits();
+ const TargetSubtargetInfo *CallerSTI = TM.getSubtargetImpl(*Caller);
+ const TargetSubtargetInfo *CalleeSTI = TM.getSubtargetImpl(*Callee);
+ FeatureBitset InlineIgnoreFeatures = CallerSTI->getInlineIgnoreFeatures();
+ FeatureBitset InlineInverseFeatures = CallerSTI->getInlineInverseFeatures();
+ FeatureBitset CallerBits =
+ (CallerSTI->getFeatureBits() ^ InlineInverseFeatures) &
+ ~InlineIgnoreFeatures;
+ FeatureBitset CalleeBits =
+ (CalleeSTI->getFeatureBits() ^ InlineInverseFeatures) &
+ ~InlineIgnoreFeatures;
// Inline a callee if its target-features are a subset of the callers
// target-features.
diff --git a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
index 6f95f0fea6441..fe71a17146184 100644
--- a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
@@ -364,6 +364,12 @@ class LLVM_ABI TargetSubtargetInfo : public MCSubtargetInfo {
}
virtual bool isRegisterReservedByUser(Register R) const { return false; }
+
+ /// Target features to ignore for inline compatibility check.
+ virtual const FeatureBitset &getInlineIgnoreFeatures() const = 0;
+ /// Target features where the callee may have an additional feature,
+ /// instead of the caller.
+ virtual const FeatureBitset &getInlineInverseFeatures() const = 0;
};
} // end namespace llvm
diff --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td
index a02a4209f86fe..53be899e0fc06 100644
--- a/llvm/include/llvm/Target/Target.td
+++ b/llvm/include/llvm/Target/Target.td
@@ -522,11 +522,23 @@ class DwarfRegAlias<Register reg> {
Register DwarfAlias = reg;
}
+// Determine whether inlining is allowed if caller and callee differ in whether
+// a feature is enabled.
+class InlineBehavior;
+
+// Arbitrary differences are allowed.
+def InlineIgnore : InlineBehavior;
+// Caller may enable more features than callee.
+def InlineDefault : InlineBehavior;
+// Callee may enable more features than caller.
+def InlineInverse : InlineBehavior;
+
//===----------------------------------------------------------------------===//
// SubtargetFeature - A characteristic of the chip set.
//
class SubtargetFeature<string n, string f, string v, string d,
- list<SubtargetFeature> i = []> {
+ list<SubtargetFeature> i = [],
+ InlineBehavior ib = InlineDefault> {
// Name - Feature name. Used by command line (-mattr=) to determine the
// appropriate target chip.
//
@@ -555,6 +567,8 @@ class SubtargetFeature<string n, string f, string v, string d,
// features isn't set, then this one shouldn't be set either.
//
list<SubtargetFeature> Implies = !sort(f, i, f.Name);
+
+ InlineBehavior InlineBehavior = ib;
}
/// Specifies a Subtarget feature that this instruction is deprecated on.
diff --git a/llvm/lib/Target/AArch64/AArch64Features.td b/llvm/lib/Target/AArch64/AArch64Features.td
index e63f4886a1256..c351a92f2f673 100644
--- a/llvm/lib/Target/AArch64/AArch64Features.td
+++ b/llvm/lib/Target/AArch64/AArch64Features.td
@@ -703,10 +703,13 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
"Disallow all unaligned memory "
"access">;
+// +execute-only callee can be inlined into caller without +execute-only,
+// but not vice versa.
def FeatureExecuteOnly : SubtargetFeature<"execute-only",
"GenExecuteOnly", "true",
"Enable the generation of "
- "execute only code.">;
+ "execute only code.",
+ [], InlineInverse>;
foreach i = {1-7,9-15,18,20-28} in
def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, "ReserveXRegister["#i#"]", "true",
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index f8d2006cbd7de..57ae3c75c07fa 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -276,10 +276,6 @@ bool AArch64TTIImpl::isMultiversionedFunction(const Function &F) const {
return F.hasFnAttribute("fmv-features");
}
-const FeatureBitset AArch64TTIImpl::InlineInverseFeatures = {
- AArch64::FeatureExecuteOnly,
-};
-
bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
const Function *Callee) const {
SMECallAttrs CallAttrs(*Caller, *Callee);
@@ -308,19 +304,7 @@ bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
return false;
}
- const TargetMachine &TM = getTLI()->getTargetMachine();
- const FeatureBitset &CallerBits =
- TM.getSubtargetImpl(*Caller)->getFeatureBits();
- const FeatureBitset &CalleeBits =
- TM.getSubtargetImpl(*Callee)->getFeatureBits();
- // Adjust the feature bitsets by inverting some of the bits. This is needed
- // for target features that represent restrictions rather than capabilities,
- // for example a "+execute-only" callee can be inlined into a caller without
- // "+execute-only", but not vice versa.
- FeatureBitset EffectiveCallerBits = CallerBits ^ InlineInverseFeatures;
- FeatureBitset EffectiveCalleeBits = CalleeBits ^ InlineInverseFeatures;
-
- return (EffectiveCallerBits & EffectiveCalleeBits) == EffectiveCalleeBits;
+ return BaseT::areInlineCompatible(Caller, Callee);
}
bool AArch64TTIImpl::areTypesABICompatible(const Function *Caller,
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index 7f07b39bd9ee5..5df5f22793cc8 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -49,8 +49,6 @@ class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
const AArch64Subtarget *ST;
const AArch64TargetLowering *TLI;
- static const FeatureBitset InlineInverseFeatures;
-
const AArch64Subtarget *getST() const { return ST; }
const AArch64TargetLowering *getTLI() const { return TLI; }
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index 2abb9c0154947..b42feda977d52 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -53,12 +53,14 @@ multiclass AMDGPUSubtargetFeature<string FeatureString,
string Description,
bit GenPredicate = 1,
bit GenAssemblerPredicate = 1,
- list<SubtargetFeature> Deps = []> {
+ list<SubtargetFeature> Deps = [],
+ InlineBehavior IB = InlineDefault> {
def Feature#NAME : SubtargetFeature<FeatureString,
"Has"#NAME,
"true",
Description,
- Deps
+ Deps,
+ IB
>;
if GenPredicate then
@@ -72,7 +74,7 @@ multiclass AMDGPUSubtargetFeature<string FeatureString,
defm FastFMAF32 : AMDGPUSubtargetFeature<"fast-fmaf",
"Assuming f32 fma is at least as fast as mul + add",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm FastDenormalF32 : AMDGPUSubtargetFeature<"fast-denormal-f32",
@@ -87,7 +89,7 @@ defm MIMG_R128 : AMDGPUSubtargetFeature<"mimg-r128",
defm HalfRate64Ops : AMDGPUSubtargetFeature<"half-rate-64-ops",
"Most fp64 instructions are half rate instead of quarter",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm FullRate64Ops : AMDGPUSubtargetFeature<"full-rate-64-ops",
@@ -144,11 +146,12 @@ defm UnalignedBufferAccess : AMDGPUSubtargetFeature<"unaligned-buffer-access",
defm TrapHandler: AMDGPUSubtargetFeature<"trap-handler",
"Trap handler support",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm UnalignedScratchAccess : AMDGPUSubtargetFeature<"unaligned-scratch-access",
- "Support unaligned scratch loads and stores"
+ "Support unaligned scratch loads and stores",
+ /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm UnalignedDSAccess : AMDGPUSubtargetFeature<"unaligned-ds-access",
@@ -204,14 +207,16 @@ defm Minimum3Maximum3PKF16 : AMDGPUSubtargetFeature<"minimum3-maximum3-pkf16",
def FeatureSupportsXNACK : SubtargetFeature<"xnack-support",
"SupportsXNACK",
"true",
- "Hardware supports XNACK"
+ "Hardware supports XNACK",
+ [], InlineIgnore
>;
defm XNACKOnOffModes : AMDGPUSubtargetFeature<"xnack-on-off-modes",
"Target supports XNACK on/off modes",
/*GenPredicate=*/1,
/*GenAssemblerPredicate=*/0,
- [FeatureSupportsXNACK]
+ [FeatureSupportsXNACK],
+ InlineIgnore
>;
// XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
@@ -225,7 +230,8 @@ def FeatureXNACK : SubtargetFeature<"xnack",
"EnableXNACK",
"true",
"Enable XNACK support",
- [FeatureSupportsXNACK]
+ [FeatureSupportsXNACK],
+ InlineIgnore
>;
def FeatureTgSplit : SubtargetFeature<"tgsplit",
@@ -245,7 +251,8 @@ def FeaturePreciseMemory
"true", "Enable precise memory mode">;
defm SGPRInitBug : AMDGPUSubtargetFeature<"sgpr-init-bug",
- "VI SGPR initialization bug requiring a fixed SGPR allocation size"
+ "VI SGPR initialization bug requiring a fixed SGPR allocation size",
+ /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm UserSGPRInit16Bug : AMDGPUSubtargetFeature<"user-sgpr-init16-bug",
@@ -1033,10 +1040,13 @@ defm DefaultComponentBroadcast : AMDGPUSubtargetFeature<"default-component-broad
"BUFFER/IMAGE store instructions set unspecified components to x component (GFX12)"
>;
+// The default assumption needs to be ecc is enabled, but no directly
+// exposed operations depend on it, so it can be safely inlined.
def FeatureSupportsSRAMECC : SubtargetFeature<"sramecc-support",
"SupportsSRAMECC",
"true",
- "Hardware supports SRAMECC"
+ "Hardware supports SRAMECC",
+ [], InlineIgnore
>;
def FeatureSRAMECC : SubtargetFeature<"sramecc",
@@ -1243,7 +1253,8 @@ def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
"EnableLoadStoreOpt",
"true",
- "Enable SI load/store optimizer pass"
+ "Enable SI load/store optimizer pass",
+ [], InlineIgnore
>;
// Performance debugging feature. Allow using DS instruction immediate
@@ -1255,13 +1266,15 @@ def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
"unsafe-ds-offset-folding",
"EnableUnsafeDSOffsetFolding",
"true",
- "Force using DS instruction immediate offsets on SI"
+ "Force using DS instruction immediate offsets on SI",
+ [], InlineIgnore
>;
def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
"EnableSIScheduler",
"true",
- "Enable SI Machine Scheduler"
+ "Enable SI Machine Scheduler",
+ [], InlineIgnore
>;
def FeatureEnableDS128 : SubtargetFeature<"enable-ds128",
@@ -1289,12 +1302,13 @@ def FeatureEnablePRTStrictNull : SubtargetFeature<"enable-prt-strict-null",
def FeatureUseFlatForGlobal : SubtargetFeature<"flat-for-global",
"UseFlatForGlobal",
"true",
- "Force to generate flat instruction for global"
+ "Force to generate flat instruction for global",
+ [], InlineIgnore
>;
defm AutoWaitcntBeforeBarrier : AMDGPUSubtargetFeature <"auto-waitcnt-before-barrier",
"Hardware automatically inserts waitcnt before barrier",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm BackOffBarrier : AMDGPUSubtargetFeature <"back-off-barrier",
@@ -1316,7 +1330,8 @@ defm KernargPreload : AMDGPUSubtargetFeature <"kernarg-preload",
// SH_MEM_CONFIG.alignment_mode
defm UnalignedAccessMode : AMDGPUSubtargetFeature<"unaligned-access-mode",
"Enable unaligned global, local and region loads and stores if the hardware"
- " supports it"
+ " supports it",
+ /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm PackedTID : AMDGPUSubtargetFeature<"packed-tid",
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index fe66a1a5d7242..40227c496a589 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -283,26 +283,6 @@ uint64_t AMDGPUTTIImpl::getMaxMemIntrinsicInlineSizeThreshold() const {
return 1024;
}
-const FeatureBitset GCNTTIImpl::InlineFeatureIgnoreList = {
- // Codegen control options which don't matter.
- AMDGPU::FeatureEnableLoadStoreOpt, AMDGPU::FeatureEnableSIScheduler,
- AMDGPU::FeatureEnableUnsafeDSOffsetFolding, AMDGPU::FeatureUseFlatForGlobal,
- AMDGPU::FeatureUnalignedScratchAccess, AMDGPU::FeatureUnalignedAccessMode,
-
- AMDGPU::FeatureAutoWaitcntBeforeBarrier,
-
- // Property of the kernel/environment which can't actually differ.
- AMDGPU::FeatureSGPRInitBug, AMDGPU::FeatureXNACK,
- AMDGPU::FeatureXNACKOnOffModes, AMDGPU::FeatureSupportsXNACK,
- AMDGPU::FeatureTrapHandler,
-
- // The default assumption needs to be ecc is enabled, but no directly
- // exposed operations depend on it, so it can be safely inlined.
- AMDGPU::FeatureSRAMECC,
-
- // Perf-tuning features
- AMDGPU::FeatureFastFMAF32, AMDGPU::FeatureHalfRate64Ops};
-
GCNTTIImpl::GCNTTIImpl(const AMDGPUTargetMachine *TM, const Function &F)
: BaseT(TM, F.getDataLayout()),
ST(static_cast<const GCNSubtarget *>(TM->getSubtargetImpl(F))),
@@ -1569,12 +1549,7 @@ bool GCNTTIImpl::areInlineCompatible(const Function *Caller,
const GCNSubtarget *CalleeST
= static_cast<const GCNSubtarget *>(TM.getSubtargetImpl(*Callee));
- const FeatureBitset &CallerBits = CallerST->getFeatureBits();
- const FeatureBitset &CalleeBits = CalleeST->getFeatureBits();
-
- FeatureBitset RealCallerBits = CallerBits & ~InlineFeatureIgnoreList;
- FeatureBitset RealCalleeBits = CalleeBits & ~InlineFeatureIgnoreList;
- if ((RealCallerBits & RealCalleeBits) != RealCalleeBits)
+ if (!BaseT::areInlineCompatible(Caller, Callee))
return false;
// FIXME: dx10_clamp can just take the caller setting, but there seems to be
diff --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 7551966cb8e15..9e833344e7341 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -44,8 +44,10 @@ def FeatureReserveEDI : SubtargetFeature<"reserve-edi", "ReservedRReg[X86::EDI]"
def FeatureX87 : SubtargetFeature<"x87","HasX87", "true",
"Enable X87 float instructions">;
+// Does not have intrinsics or ABI effects.
def FeatureNOPL : SubtargetFeature<"nopl", "HasNOPL", "true",
- "Enable NOPL instruction (generally pentium pro+)">;
+ "Enable NOPL instruction (generally pentium pro+)",
+ [], InlineIgnore>;
def FeatureCMOV : SubtargetFeature<"cmov","HasCMOV", "true",
"Enable conditional move instructions">;
@@ -104,10 +106,12 @@ def FeatureMMX : SubtargetFeature<"mmx","HasMMX", "true",
// without disabling 64-bit mode. Nothing should imply this feature bit. It
// is used to enforce that only 64-bit capable CPUs are used in 64-bit mode.
def FeatureX86_64 : SubtargetFeature<"64bit", "HasX86_64", "true",
- "Support 64-bit instructions">;
+ "Support 64-bit instructions", [],
+ InlineIgnore>;
+// TODO: This should not be InlineIgnore, as it affects the atomics ABI.
def FeatureCX16 : SubtargetFeature<"cx16", "HasCX16", "true",
"64-bit with cmpxchg16b (this is true for most x86-64 chips, but not the first AMD chips)",
- [FeatureCX8]>;
+ [FeatureCX8], InlineIgnore>;
def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
"Support SSE 4a instructions",
[FeatureSSE3]>;
@@ -204,9 +208,10 @@ def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
"Enable XOP instructions",
[FeatureFMA4]>;
-def FeatureSSEUnalignedMem : SubtargetFeature<"sse-unaligned-mem",
- "HasSSEUnalignedMem", "true",
- "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)">;
+def FeatureSSEUnalignedMem : SubtargetFeature<
+ "sse-unaligned-mem", "HasSSEUnalignedMem", "true",
+ "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)",
+ [], InlineIgnore>;
def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
"Enable AES instructions",
[FeatureSSE2]>;
@@ -253,8 +258,10 @@ def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
"Support PRFCHW instructions">;
def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
"Support RDSEED instruction">;
+// Does not have intrinsics or ABI effects.
def FeatureLAHFSAHF64 : SubtargetFeature<"sahf", "HasLAHFSAHF64", "true",
- "Support LAHF and SAHF instructions in 64-bit mode">;
+ "Support LAHF and SAHF instructions in 64-bit mode",
+ [], InlineIgnore>;
def FeatureMWAITX : SubtargetFeature<"mwaitx", "HasMWAITX", "true",
"Enable MONITORX/MWAITX timer functionality">;
def FeatureCLZERO : SubtargetFeature<"clzero", "HasCLZERO", "true",
@@ -488,55 +495,67 @@ def FeatureHardenSlsIJmp
//===----------------------------------------------------------------------===//
def TuningPreferMovmskOverVTest : SubtargetFeature<"prefer-movmsk-over-vtest",
"PreferMovmskOverVTest", "true",
- "Prefer movmsk over vtest instruction">;
+ "Prefer movmsk over vtest instruction",
+ [], InlineIgnore>;
def TuningSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true",
- "SHLD instruction is slow">;
+ "SHLD instruction is slow",
+ [], InlineIgnore>;
def TuningSlowPMULLD : SubtargetFeature<"slow-pmulld", "IsPMULLDSlow", "true",
- "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)">;
+ "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)",
+ [], InlineIgnore>;
def TuningSlowPMULLQ : SubtargetFeature<"slow-pmullq", "IsPMULLQSlow", "true",
- "PMULLQ instruction is slow">;
+ "PMULLQ instruction is slow",
+ [], Inline...
[truncated]
|
|
@llvm/pr-subscribers-backend-x86 Author: Nikita Popov (nikic) ChangesThis allows specifying the InliningBehavior as part of SubtargetFeature. The behavior is one of InlineDefault, InlineInverse, and InlineIgnore.
The default areInlineCompatible() implementation respects these now. The intention behind this change is that it reduces the risk of forgetting to update feature lists in TTI when adding a new feature, e.g. when adding a new tuning flag that should be InlineIgnore. Move X86 and AMDGPU ignored features, and the one inverse feature on AArch64 to TableGen. There is various followup work to do here, e.g. currently tuning flags on AArch64 are not ignored (and on AMDGPU only some are ignored). Patch is 53.03 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/205348.diff 14 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index d64cda740a77f..8c4df6664cf1d 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -397,10 +397,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
const Function *Callee) const override {
const TargetMachine &TM = getTLI()->getTargetMachine();
- const FeatureBitset &CallerBits =
- TM.getSubtargetImpl(*Caller)->getFeatureBits();
- const FeatureBitset &CalleeBits =
- TM.getSubtargetImpl(*Callee)->getFeatureBits();
+ const TargetSubtargetInfo *CallerSTI = TM.getSubtargetImpl(*Caller);
+ const TargetSubtargetInfo *CalleeSTI = TM.getSubtargetImpl(*Callee);
+ FeatureBitset InlineIgnoreFeatures = CallerSTI->getInlineIgnoreFeatures();
+ FeatureBitset InlineInverseFeatures = CallerSTI->getInlineInverseFeatures();
+ FeatureBitset CallerBits =
+ (CallerSTI->getFeatureBits() ^ InlineInverseFeatures) &
+ ~InlineIgnoreFeatures;
+ FeatureBitset CalleeBits =
+ (CalleeSTI->getFeatureBits() ^ InlineInverseFeatures) &
+ ~InlineIgnoreFeatures;
// Inline a callee if its target-features are a subset of the callers
// target-features.
diff --git a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
index 6f95f0fea6441..fe71a17146184 100644
--- a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
@@ -364,6 +364,12 @@ class LLVM_ABI TargetSubtargetInfo : public MCSubtargetInfo {
}
virtual bool isRegisterReservedByUser(Register R) const { return false; }
+
+ /// Target features to ignore for inline compatibility check.
+ virtual const FeatureBitset &getInlineIgnoreFeatures() const = 0;
+ /// Target features where the callee may have an additional feature,
+ /// instead of the caller.
+ virtual const FeatureBitset &getInlineInverseFeatures() const = 0;
};
} // end namespace llvm
diff --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td
index a02a4209f86fe..53be899e0fc06 100644
--- a/llvm/include/llvm/Target/Target.td
+++ b/llvm/include/llvm/Target/Target.td
@@ -522,11 +522,23 @@ class DwarfRegAlias<Register reg> {
Register DwarfAlias = reg;
}
+// Determine whether inlining is allowed if caller and callee differ in whether
+// a feature is enabled.
+class InlineBehavior;
+
+// Arbitrary differences are allowed.
+def InlineIgnore : InlineBehavior;
+// Caller may enable more features than callee.
+def InlineDefault : InlineBehavior;
+// Callee may enable more features than caller.
+def InlineInverse : InlineBehavior;
+
//===----------------------------------------------------------------------===//
// SubtargetFeature - A characteristic of the chip set.
//
class SubtargetFeature<string n, string f, string v, string d,
- list<SubtargetFeature> i = []> {
+ list<SubtargetFeature> i = [],
+ InlineBehavior ib = InlineDefault> {
// Name - Feature name. Used by command line (-mattr=) to determine the
// appropriate target chip.
//
@@ -555,6 +567,8 @@ class SubtargetFeature<string n, string f, string v, string d,
// features isn't set, then this one shouldn't be set either.
//
list<SubtargetFeature> Implies = !sort(f, i, f.Name);
+
+ InlineBehavior InlineBehavior = ib;
}
/// Specifies a Subtarget feature that this instruction is deprecated on.
diff --git a/llvm/lib/Target/AArch64/AArch64Features.td b/llvm/lib/Target/AArch64/AArch64Features.td
index e63f4886a1256..c351a92f2f673 100644
--- a/llvm/lib/Target/AArch64/AArch64Features.td
+++ b/llvm/lib/Target/AArch64/AArch64Features.td
@@ -703,10 +703,13 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
"Disallow all unaligned memory "
"access">;
+// +execute-only callee can be inlined into caller without +execute-only,
+// but not vice versa.
def FeatureExecuteOnly : SubtargetFeature<"execute-only",
"GenExecuteOnly", "true",
"Enable the generation of "
- "execute only code.">;
+ "execute only code.",
+ [], InlineInverse>;
foreach i = {1-7,9-15,18,20-28} in
def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, "ReserveXRegister["#i#"]", "true",
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index f8d2006cbd7de..57ae3c75c07fa 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -276,10 +276,6 @@ bool AArch64TTIImpl::isMultiversionedFunction(const Function &F) const {
return F.hasFnAttribute("fmv-features");
}
-const FeatureBitset AArch64TTIImpl::InlineInverseFeatures = {
- AArch64::FeatureExecuteOnly,
-};
-
bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
const Function *Callee) const {
SMECallAttrs CallAttrs(*Caller, *Callee);
@@ -308,19 +304,7 @@ bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
return false;
}
- const TargetMachine &TM = getTLI()->getTargetMachine();
- const FeatureBitset &CallerBits =
- TM.getSubtargetImpl(*Caller)->getFeatureBits();
- const FeatureBitset &CalleeBits =
- TM.getSubtargetImpl(*Callee)->getFeatureBits();
- // Adjust the feature bitsets by inverting some of the bits. This is needed
- // for target features that represent restrictions rather than capabilities,
- // for example a "+execute-only" callee can be inlined into a caller without
- // "+execute-only", but not vice versa.
- FeatureBitset EffectiveCallerBits = CallerBits ^ InlineInverseFeatures;
- FeatureBitset EffectiveCalleeBits = CalleeBits ^ InlineInverseFeatures;
-
- return (EffectiveCallerBits & EffectiveCalleeBits) == EffectiveCalleeBits;
+ return BaseT::areInlineCompatible(Caller, Callee);
}
bool AArch64TTIImpl::areTypesABICompatible(const Function *Caller,
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index 7f07b39bd9ee5..5df5f22793cc8 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -49,8 +49,6 @@ class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
const AArch64Subtarget *ST;
const AArch64TargetLowering *TLI;
- static const FeatureBitset InlineInverseFeatures;
-
const AArch64Subtarget *getST() const { return ST; }
const AArch64TargetLowering *getTLI() const { return TLI; }
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index 2abb9c0154947..b42feda977d52 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -53,12 +53,14 @@ multiclass AMDGPUSubtargetFeature<string FeatureString,
string Description,
bit GenPredicate = 1,
bit GenAssemblerPredicate = 1,
- list<SubtargetFeature> Deps = []> {
+ list<SubtargetFeature> Deps = [],
+ InlineBehavior IB = InlineDefault> {
def Feature#NAME : SubtargetFeature<FeatureString,
"Has"#NAME,
"true",
Description,
- Deps
+ Deps,
+ IB
>;
if GenPredicate then
@@ -72,7 +74,7 @@ multiclass AMDGPUSubtargetFeature<string FeatureString,
defm FastFMAF32 : AMDGPUSubtargetFeature<"fast-fmaf",
"Assuming f32 fma is at least as fast as mul + add",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm FastDenormalF32 : AMDGPUSubtargetFeature<"fast-denormal-f32",
@@ -87,7 +89,7 @@ defm MIMG_R128 : AMDGPUSubtargetFeature<"mimg-r128",
defm HalfRate64Ops : AMDGPUSubtargetFeature<"half-rate-64-ops",
"Most fp64 instructions are half rate instead of quarter",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm FullRate64Ops : AMDGPUSubtargetFeature<"full-rate-64-ops",
@@ -144,11 +146,12 @@ defm UnalignedBufferAccess : AMDGPUSubtargetFeature<"unaligned-buffer-access",
defm TrapHandler: AMDGPUSubtargetFeature<"trap-handler",
"Trap handler support",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm UnalignedScratchAccess : AMDGPUSubtargetFeature<"unaligned-scratch-access",
- "Support unaligned scratch loads and stores"
+ "Support unaligned scratch loads and stores",
+ /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm UnalignedDSAccess : AMDGPUSubtargetFeature<"unaligned-ds-access",
@@ -204,14 +207,16 @@ defm Minimum3Maximum3PKF16 : AMDGPUSubtargetFeature<"minimum3-maximum3-pkf16",
def FeatureSupportsXNACK : SubtargetFeature<"xnack-support",
"SupportsXNACK",
"true",
- "Hardware supports XNACK"
+ "Hardware supports XNACK",
+ [], InlineIgnore
>;
defm XNACKOnOffModes : AMDGPUSubtargetFeature<"xnack-on-off-modes",
"Target supports XNACK on/off modes",
/*GenPredicate=*/1,
/*GenAssemblerPredicate=*/0,
- [FeatureSupportsXNACK]
+ [FeatureSupportsXNACK],
+ InlineIgnore
>;
// XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
@@ -225,7 +230,8 @@ def FeatureXNACK : SubtargetFeature<"xnack",
"EnableXNACK",
"true",
"Enable XNACK support",
- [FeatureSupportsXNACK]
+ [FeatureSupportsXNACK],
+ InlineIgnore
>;
def FeatureTgSplit : SubtargetFeature<"tgsplit",
@@ -245,7 +251,8 @@ def FeaturePreciseMemory
"true", "Enable precise memory mode">;
defm SGPRInitBug : AMDGPUSubtargetFeature<"sgpr-init-bug",
- "VI SGPR initialization bug requiring a fixed SGPR allocation size"
+ "VI SGPR initialization bug requiring a fixed SGPR allocation size",
+ /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm UserSGPRInit16Bug : AMDGPUSubtargetFeature<"user-sgpr-init16-bug",
@@ -1033,10 +1040,13 @@ defm DefaultComponentBroadcast : AMDGPUSubtargetFeature<"default-component-broad
"BUFFER/IMAGE store instructions set unspecified components to x component (GFX12)"
>;
+// The default assumption needs to be ecc is enabled, but no directly
+// exposed operations depend on it, so it can be safely inlined.
def FeatureSupportsSRAMECC : SubtargetFeature<"sramecc-support",
"SupportsSRAMECC",
"true",
- "Hardware supports SRAMECC"
+ "Hardware supports SRAMECC",
+ [], InlineIgnore
>;
def FeatureSRAMECC : SubtargetFeature<"sramecc",
@@ -1243,7 +1253,8 @@ def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
"EnableLoadStoreOpt",
"true",
- "Enable SI load/store optimizer pass"
+ "Enable SI load/store optimizer pass",
+ [], InlineIgnore
>;
// Performance debugging feature. Allow using DS instruction immediate
@@ -1255,13 +1266,15 @@ def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
"unsafe-ds-offset-folding",
"EnableUnsafeDSOffsetFolding",
"true",
- "Force using DS instruction immediate offsets on SI"
+ "Force using DS instruction immediate offsets on SI",
+ [], InlineIgnore
>;
def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
"EnableSIScheduler",
"true",
- "Enable SI Machine Scheduler"
+ "Enable SI Machine Scheduler",
+ [], InlineIgnore
>;
def FeatureEnableDS128 : SubtargetFeature<"enable-ds128",
@@ -1289,12 +1302,13 @@ def FeatureEnablePRTStrictNull : SubtargetFeature<"enable-prt-strict-null",
def FeatureUseFlatForGlobal : SubtargetFeature<"flat-for-global",
"UseFlatForGlobal",
"true",
- "Force to generate flat instruction for global"
+ "Force to generate flat instruction for global",
+ [], InlineIgnore
>;
defm AutoWaitcntBeforeBarrier : AMDGPUSubtargetFeature <"auto-waitcnt-before-barrier",
"Hardware automatically inserts waitcnt before barrier",
- /*GenPredicate=*/0
+ /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm BackOffBarrier : AMDGPUSubtargetFeature <"back-off-barrier",
@@ -1316,7 +1330,8 @@ defm KernargPreload : AMDGPUSubtargetFeature <"kernarg-preload",
// SH_MEM_CONFIG.alignment_mode
defm UnalignedAccessMode : AMDGPUSubtargetFeature<"unaligned-access-mode",
"Enable unaligned global, local and region loads and stores if the hardware"
- " supports it"
+ " supports it",
+ /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
>;
defm PackedTID : AMDGPUSubtargetFeature<"packed-tid",
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index fe66a1a5d7242..40227c496a589 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -283,26 +283,6 @@ uint64_t AMDGPUTTIImpl::getMaxMemIntrinsicInlineSizeThreshold() const {
return 1024;
}
-const FeatureBitset GCNTTIImpl::InlineFeatureIgnoreList = {
- // Codegen control options which don't matter.
- AMDGPU::FeatureEnableLoadStoreOpt, AMDGPU::FeatureEnableSIScheduler,
- AMDGPU::FeatureEnableUnsafeDSOffsetFolding, AMDGPU::FeatureUseFlatForGlobal,
- AMDGPU::FeatureUnalignedScratchAccess, AMDGPU::FeatureUnalignedAccessMode,
-
- AMDGPU::FeatureAutoWaitcntBeforeBarrier,
-
- // Property of the kernel/environment which can't actually differ.
- AMDGPU::FeatureSGPRInitBug, AMDGPU::FeatureXNACK,
- AMDGPU::FeatureXNACKOnOffModes, AMDGPU::FeatureSupportsXNACK,
- AMDGPU::FeatureTrapHandler,
-
- // The default assumption needs to be ecc is enabled, but no directly
- // exposed operations depend on it, so it can be safely inlined.
- AMDGPU::FeatureSRAMECC,
-
- // Perf-tuning features
- AMDGPU::FeatureFastFMAF32, AMDGPU::FeatureHalfRate64Ops};
-
GCNTTIImpl::GCNTTIImpl(const AMDGPUTargetMachine *TM, const Function &F)
: BaseT(TM, F.getDataLayout()),
ST(static_cast<const GCNSubtarget *>(TM->getSubtargetImpl(F))),
@@ -1569,12 +1549,7 @@ bool GCNTTIImpl::areInlineCompatible(const Function *Caller,
const GCNSubtarget *CalleeST
= static_cast<const GCNSubtarget *>(TM.getSubtargetImpl(*Callee));
- const FeatureBitset &CallerBits = CallerST->getFeatureBits();
- const FeatureBitset &CalleeBits = CalleeST->getFeatureBits();
-
- FeatureBitset RealCallerBits = CallerBits & ~InlineFeatureIgnoreList;
- FeatureBitset RealCalleeBits = CalleeBits & ~InlineFeatureIgnoreList;
- if ((RealCallerBits & RealCalleeBits) != RealCalleeBits)
+ if (!BaseT::areInlineCompatible(Caller, Callee))
return false;
// FIXME: dx10_clamp can just take the caller setting, but there seems to be
diff --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 7551966cb8e15..9e833344e7341 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -44,8 +44,10 @@ def FeatureReserveEDI : SubtargetFeature<"reserve-edi", "ReservedRReg[X86::EDI]"
def FeatureX87 : SubtargetFeature<"x87","HasX87", "true",
"Enable X87 float instructions">;
+// Does not have intrinsics or ABI effects.
def FeatureNOPL : SubtargetFeature<"nopl", "HasNOPL", "true",
- "Enable NOPL instruction (generally pentium pro+)">;
+ "Enable NOPL instruction (generally pentium pro+)",
+ [], InlineIgnore>;
def FeatureCMOV : SubtargetFeature<"cmov","HasCMOV", "true",
"Enable conditional move instructions">;
@@ -104,10 +106,12 @@ def FeatureMMX : SubtargetFeature<"mmx","HasMMX", "true",
// without disabling 64-bit mode. Nothing should imply this feature bit. It
// is used to enforce that only 64-bit capable CPUs are used in 64-bit mode.
def FeatureX86_64 : SubtargetFeature<"64bit", "HasX86_64", "true",
- "Support 64-bit instructions">;
+ "Support 64-bit instructions", [],
+ InlineIgnore>;
+// TODO: This should not be InlineIgnore, as it affects the atomics ABI.
def FeatureCX16 : SubtargetFeature<"cx16", "HasCX16", "true",
"64-bit with cmpxchg16b (this is true for most x86-64 chips, but not the first AMD chips)",
- [FeatureCX8]>;
+ [FeatureCX8], InlineIgnore>;
def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
"Support SSE 4a instructions",
[FeatureSSE3]>;
@@ -204,9 +208,10 @@ def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
"Enable XOP instructions",
[FeatureFMA4]>;
-def FeatureSSEUnalignedMem : SubtargetFeature<"sse-unaligned-mem",
- "HasSSEUnalignedMem", "true",
- "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)">;
+def FeatureSSEUnalignedMem : SubtargetFeature<
+ "sse-unaligned-mem", "HasSSEUnalignedMem", "true",
+ "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)",
+ [], InlineIgnore>;
def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
"Enable AES instructions",
[FeatureSSE2]>;
@@ -253,8 +258,10 @@ def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
"Support PRFCHW instructions">;
def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
"Support RDSEED instruction">;
+// Does not have intrinsics or ABI effects.
def FeatureLAHFSAHF64 : SubtargetFeature<"sahf", "HasLAHFSAHF64", "true",
- "Support LAHF and SAHF instructions in 64-bit mode">;
+ "Support LAHF and SAHF instructions in 64-bit mode",
+ [], InlineIgnore>;
def FeatureMWAITX : SubtargetFeature<"mwaitx", "HasMWAITX", "true",
"Enable MONITORX/MWAITX timer functionality">;
def FeatureCLZERO : SubtargetFeature<"clzero", "HasCLZERO", "true",
@@ -488,55 +495,67 @@ def FeatureHardenSlsIJmp
//===----------------------------------------------------------------------===//
def TuningPreferMovmskOverVTest : SubtargetFeature<"prefer-movmsk-over-vtest",
"PreferMovmskOverVTest", "true",
- "Prefer movmsk over vtest instruction">;
+ "Prefer movmsk over vtest instruction",
+ [], InlineIgnore>;
def TuningSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true",
- "SHLD instruction is slow">;
+ "SHLD instruction is slow",
+ [], InlineIgnore>;
def TuningSlowPMULLD : SubtargetFeature<"slow-pmulld", "IsPMULLDSlow", "true",
- "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)">;
+ "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)",
+ [], InlineIgnore>;
def TuningSlowPMULLQ : SubtargetFeature<"slow-pmullq", "IsPMULLQSlow", "true",
- "PMULLQ instruction is slow">;
+ "PMULLQ instruction is slow",
+ [], Inline...
[truncated]
|
| // Caller may enable more features than callee. | ||
| def InlineDefault : InlineBehavior; | ||
| // Callee may enable more features than caller. | ||
| def InlineInverse : InlineBehavior; |
There was a problem hiding this comment.
I don't understand "more" and "less". The number of subtarget features can't be significant.
There was a problem hiding this comment.
I updated the comments, is it clearer now?
| // Allow caller to enable feature even if callee does not. | ||
| // (InlineDefault caller features are a superset of callee features.) | ||
| def InlineDefault : InlineBehavior; |
There was a problem hiding this comment.
I think it is equivalent and clearer to say "a callee with this feature enabled cannot be inlined to a caller without it enabled".
And then below for InlineInverse - "a callee without this feature enabled cannot be inlined into a caller with it enabled".
Talking about subsets/supersets is less useful IMO because these behaviours are declared for individual features rather than groups of them.
There was a problem hiding this comment.
Yeah, that makes sense. I've adopted your wording.
This allows specifying the InliningBehavior as part of SubtargetFeature. The behavior is one of InlineDefault, InlineInverse, and InlineIgnore. * InlineDefault: A callee with this feature enabled cannot be inlined into a caller without it enabled. * InlineInverse: A callee without this feature enabled cannot be inlined into a caller with it enabled. * InlineIgnore: Arbitrary differences are allowed. The default areInlineCompatible() implementation respects these now. The intention behind this change is that it reduces the risk of forgetting to update feature lists in TTI when adding a new feature, e.g. when adding a new tuning flag that should be InlineIgnore. Move X86 and AMDGPU ignored features, and the one inverse feature on AArch64 to TableGen. There is various followup work to do here, e.g. currently tuning flags on AArch64 are not ignored (and on AMDGPU only some are ignored).
…#205113) If inlining is unsound due to incompatible target feature attributes, we should not inline the call even if alwaysinline is set. This will likely result in a crash during instruction selection. We tried this previously in d6f994a, but the change had to be reverted because the quality of our areInlineCompatible() hooks was very bad at the time, which resulted in inlining not happening in many cases where it was safe. I think we're in a much better position now. Most notably, we now have a default areInlineCompatible() implementation that actually does something sensible (#117493), inlining compatibility for target features is now specified in TableGen (#205348). Various target-specific issues have been fixed as well, e.g. ARM's overly strict feature whitelist (#205763) and X86's overly conservative ABI compatibility checks (#205106).
…et features (#205113) If inlining is unsound due to incompatible target feature attributes, we should not inline the call even if alwaysinline is set. This will likely result in a crash during instruction selection. We tried this previously in llvm/llvm-project@d6f994a, but the change had to be reverted because the quality of our areInlineCompatible() hooks was very bad at the time, which resulted in inlining not happening in many cases where it was safe. I think we're in a much better position now. Most notably, we now have a default areInlineCompatible() implementation that actually does something sensible (llvm/llvm-project#117493), inlining compatibility for target features is now specified in TableGen (llvm/llvm-project#205348). Various target-specific issues have been fixed as well, e.g. ARM's overly strict feature whitelist (llvm/llvm-project#205763) and X86's overly conservative ABI compatibility checks (llvm/llvm-project#205106).
…et features (#205113) If inlining is unsound due to incompatible target feature attributes, we should not inline the call even if alwaysinline is set. This will likely result in a crash during instruction selection. We tried this previously in llvm/llvm-project@d6f994a, but the change had to be reverted because the quality of our areInlineCompatible() hooks was very bad at the time, which resulted in inlining not happening in many cases where it was safe. I think we're in a much better position now. Most notably, we now have a default areInlineCompatible() implementation that actually does something sensible (llvm/llvm-project#117493), inlining compatibility for target features is now specified in TableGen (llvm/llvm-project#205348). Various target-specific issues have been fixed as well, e.g. ARM's overly strict feature whitelist (llvm/llvm-project#205763) and X86's overly conservative ABI compatibility checks (llvm/llvm-project#205106).
…et features (#205113) If inlining is unsound due to incompatible target feature attributes, we should not inline the call even if alwaysinline is set. This will likely result in a crash during instruction selection. We tried this previously in llvm/llvm-project@d6f994a, but the change had to be reverted because the quality of our areInlineCompatible() hooks was very bad at the time, which resulted in inlining not happening in many cases where it was safe. I think we're in a much better position now. Most notably, we now have a default areInlineCompatible() implementation that actually does something sensible (llvm/llvm-project#117493), inlining compatibility for target features is now specified in TableGen (llvm/llvm-project#205348). Various target-specific issues have been fixed as well, e.g. ARM's overly strict feature whitelist (llvm/llvm-project#205763) and X86's overly conservative ABI compatibility checks (llvm/llvm-project#205106).
This allows specifying the InliningBehavior as part of SubtargetFeature. The behavior is one of InlineDefault, InlineInverse, and InlineIgnore.
The default areInlineCompatible() implementation respects these now.
The intention behind this change is that it reduces the risk of forgetting to update feature lists in TTI when adding a new feature, e.g. when adding a new tuning flag that should be InlineIgnore.
Move X86 and AMDGPU ignored features, and the one inverse feature on AArch64 to TableGen.
There is various followup work to do here, e.g. currently tuning flags on AArch64 are not ignored (and on AMDGPU only some are ignored).