Skip to content

[RISCV] Disallow target attribute use in multiversioning #85899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11912,8 +11912,14 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
return false;
}

const llvm::Triple &T = S.getASTContext().getTargetInfo().getTriple();

// Target attribute on AArch64 is not used for multiversioning
if (NewTA && S.getASTContext().getTargetInfo().getTriple().isAArch64())
if (NewTA && T.isAArch64())
return false;

// Target attribute on RISCV is not used for multiversioning
if (NewTA && T.isRISCV())
return false;

if (!OldDecl || !OldDecl->getAsFunction() ||
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Sema/attr-target-riscv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %clang_cc1 -triple riscv64-linux-gnu -target-feature +i -fsyntax-only -verify -std=c2x %s

//expected-note@+1 {{previous definition is here}}
int __attribute__((target("arch=rv64g"))) foo(void) { return 0; }
//expected-error@+1 {{redefinition of 'foo'}}
int __attribute__((target("arch=rv64gc"))) foo(void) { return 0; }