mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 19:24:21 +00:00
[AArch64] Fix FMV crash on unspecified number of parameters function (#65671)
Fix Function Multi Versioning crash reported in https://github.com/llvm/llvm-project/issues/65669
This commit is contained in:
parent
8c03239934
commit
e5fe3d27fc
@ -11680,20 +11680,22 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
|
||||
FunctionDecl *OldFD = OldDecl->getAsFunction();
|
||||
|
||||
if (!OldFD->isMultiVersion() && MVKind == MultiVersionKind::None) {
|
||||
// No target_version attributes mean default
|
||||
if (!NewTVA) {
|
||||
const auto *OldTVA = OldFD->getAttr<TargetVersionAttr>();
|
||||
if (OldTVA) {
|
||||
NewFD->addAttr(TargetVersionAttr::CreateImplicit(
|
||||
S.Context, "default", NewFD->getSourceRange()));
|
||||
NewFD->setIsMultiVersion();
|
||||
OldFD->setIsMultiVersion();
|
||||
OldDecl = OldFD;
|
||||
Redeclaration = true;
|
||||
return true;
|
||||
}
|
||||
if (NewTVA || !OldFD->getAttr<TargetVersionAttr>())
|
||||
return false;
|
||||
if (!NewFD->getType()->getAs<FunctionProtoType>()) {
|
||||
// Multiversion declaration doesn't have prototype.
|
||||
S.Diag(NewFD->getLocation(), diag::err_multiversion_noproto);
|
||||
NewFD->setInvalidDecl();
|
||||
} else {
|
||||
// No "target_version" attribute is equivalent to "default" attribute.
|
||||
NewFD->addAttr(TargetVersionAttr::CreateImplicit(
|
||||
S.Context, "default", NewFD->getSourceRange()));
|
||||
NewFD->setIsMultiVersion();
|
||||
OldFD->setIsMultiVersion();
|
||||
OldDecl = OldFD;
|
||||
Redeclaration = true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Multiversioned redeclarations aren't allowed to omit the attribute, except
|
||||
|
@ -89,3 +89,8 @@ float __attribute__((target_version("rdm"))) rtype(int);
|
||||
int __attribute__((target_version("sha2"))) combine(void) { return 1; }
|
||||
// expected-error@+1 {{multiversioned function declaration has a different calling convention}}
|
||||
int __attribute__((aarch64_vector_pcs, target_version("sha3"))) combine(void) { return 2; }
|
||||
|
||||
int __attribute__((target_version("fp+aes+pmull+rcpc"))) unspec_args() { return -1; }
|
||||
// expected-error@+1 {{multiversioned function must have a prototype}}
|
||||
int __attribute__((target_version("default"))) unspec_args() { return 0; }
|
||||
int cargs() { return unspec_args(); }
|
||||
|
Loading…
Reference in New Issue
Block a user