================
@@ -1275,6 +1299,28 @@ GCNTargetMachine::getSubtargetImpl(const Function &F) 
const {
 
   auto &I = SubtargetMap[SubtargetKey];
   if (!I) {
+    AMDGPU::GPUKind Kind = AMDGPU::parseArchAMDGCN(GPU);
+    Triple::SubArchType GPUSubArch = AMDGPU::getSubArch(Kind);
+
+    // Enforce the subtarget is covered by the subarch. Tolerate no subarch for
+    // legacy compatibility.
+    const Triple &TT = getTargetTriple();
+    if (GPUSubArch != TT.getSubArch()) {
+      // Check if this is a generic subarch which has subtargets. Ignore
+      // unknown subtargets with a known subarch, since for whatever reason
+      // the convention is to just print a warning and ignore unrecognized
+      // subtargets.
+      if (Kind != AMDGPU::GK_NONE &&
+          TT.getSubArch() != AMDGPU::getMajorSubArch(GPUSubArch)) {
+        bool IsLegacyEmptySubArch = TT.getSubArch() == Triple::NoSubArch;
+        if (!IsLegacyEmptySubArch &&
+            AMDGPU::getMajorSubArch(GPUSubArch) != TT.getSubArch()) {
----------------
ro-i wrote:

re-tests `TT.getSubArch() != AMDGPU::getMajorSubArch(GPUSubArch)` from the 
parent if

https://github.com/llvm/llvm-project/pull/206480
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to