[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
Tomas Matheson via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 28 08:20:39 PDT 2024
================
@@ -11523,10 +11525,17 @@ static bool CheckTargetCausesMultiVersioning(Sema &S, FunctionDecl *OldFD,
const auto *OldTVA = OldFD->getAttr<TargetVersionAttr>();
// If the old decl is NOT MultiVersioned yet, and we don't cause that
// to change, this is a simple redeclaration.
- if ((NewTA && !NewTA->isDefaultVersion() &&
- (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) ||
- (NewTVA && !NewTVA->isDefaultVersion() &&
- (!OldTVA || OldTVA->getName() == NewTVA->getName())))
+ if (NewTA && !NewTA->isDefaultVersion() &&
+ (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
+ return false;
+
+ // The target_version attribute only causes Multiversioning if this
+ // declaration is NOT the default version. Moreover, the old declaration
+ // must be the default version (either explicitly via the attribute,
+ // or implicitly without it).
+ if (NewTVA && NewTVA->isDefaultVersion())
+ return false;
+ if (NewTVA && OldTVA && !OldTVA->isDefaultVersion())
return false;
----------------
tmatheson-arm wrote:
```suggestion
```
We already know that `!isMultiVersioned()` at this point, because of the call site (and assert at the top of the function). Presumably these checks for the old version have already been done?
https://github.com/llvm/llvm-project/pull/96628
More information about the cfe-commits
mailing list