[clang] [Sema] Disallow 'target' attribute for multiversioning (PR #236782)

Wael Yehia via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 29 09:57:52 PDT 2026


================
@@ -12365,13 +12366,17 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
     return false;
   }
 
-  // Target attribute on AArch64 is not used for multiversioning
-  if (NewTA && TI.getTriple().isAArch64())
-    return false;
-
-  // Target attribute on RISCV is not used for multiversioning
-  if (NewTA && TI.getTriple().isRISCV())
+  // Target attribute is not used for multiversioning on AArch64, RISC-V or AIX.
+  if (NewTA && (TI.getTriple().isAArch64() || TI.getTriple().isRISCV() ||
+                TI.getTriple().isOSAIX())) {
+    if (Redeclaration) {
----------------
w2yehia wrote:

this breaks the following:
```
__attribute__((target("cpu=pwr10"))) int f(void) { return 1; }
__attribute__((target("cpu=pwr10"))) int f(void);

int g(void) { return f(); }
```

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


More information about the cfe-commits mailing list