[clang] [llvm] [Clang][X86] Resolve target_clones calls through GlobalOpt (PR #230278)

Oleksandr Kulkov via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 6 03:50:00 PST 2026


================
@@ -3581,6 +3556,16 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
       Attrs.addAttribute("fmv-features", FMVFeatures.substr(1));
       AddedAttr = true;
     }
+  } else if (getTarget().getTriple().isX86() && getTarget().supportsIFunc() &&
+             TC) {
+    auto Arch = TC->getX86Architecture(GD.getMultiVersionIndex());
+    // CPU-model checks cannot be represented by feature masks.
----------------
adamant-pwn wrote:

`arch=haswell` selects by CPU identity. Another CPU can support the same ISA features without satisfying that predicate, so representing it as a feature mask could select the wrong clone. I've expanded the comment to explain why these versions retain runtime dispatch.

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


More information about the cfe-commits mailing list