[llvm] [TableGen] Print a warning when a Processor contains duplicate Features / TuneFeatures (PR #137864)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 14:26:54 PDT 2025
================
@@ -333,6 +333,30 @@ unsigned SubtargetEmitter::cpuNames(raw_ostream &OS) {
return Names.size();
}
+static void checkDuplicateCPUFeatures(StringRef CPUName,
+ ArrayRef<const Record *> Features,
+ ArrayRef<const Record *> TuneFeatures) {
+ // We had made sure each SubtargetFeature Record has a unique name, so we can
+ // simply use pointer sets here.
+ SmallPtrSet<const Record *, 8> FeatureSet, TuneFeatureSet;
+ for (const auto *FeatureRec : Features) {
+ if (!FeatureSet.insert(FeatureRec).second)
+ PrintWarning("Processor " + CPUName + " contains duplicate feature '" +
+ FeatureRec->getValueAsString("Name") + "'");
+ }
+
+ for (const auto *TuneFeatureRec : TuneFeatures) {
+ if (!TuneFeatureSet.insert(TuneFeatureRec).second)
+ PrintWarning("Processor " + CPUName +
+ " contains duplicate tune feature '" +
+ TuneFeatureRec->getValueAsString("Name") + "'");
+ if (FeatureSet.count(TuneFeatureRec))
----------------
jurahul wrote:
nit: FeatureSer.contains() for a more canonical form?
https://github.com/llvm/llvm-project/pull/137864
More information about the llvm-commits
mailing list