-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix the buildbot failure caused by heap use-after-free error. Origin message: This patch enable `target_version` attribute for RISC-V target. The proposal of `target_version` syntax can be found at the riscv-non-isa/riscv-c-api-doc#48 (which has landed), as modified by the proposed riscv-non-isa/riscv-c-api-doc#85 (which adds the priority syntax). `target_version` attribute will trigger the function multi-versioning feature and act like `target_clones` attribute. See #85786 for the implementation of `target_clones`.
- Loading branch information
Showing
8 changed files
with
1,082 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: not %clang_cc1 -triple riscv64 -target-feature +i -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORT-OS | ||
|
||
// CHECK-UNSUPPORT-OS: error: function multiversioning is currently only supported on Linux | ||
__attribute__((target_version("default"))) int foo(void) { | ||
return 2; | ||
} | ||
|
||
__attribute__((target_version("arch=+c"))) int foo(void) { | ||
return 2; | ||
} | ||
|
||
|
||
int bar() { return foo(); } |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// RUN: %clang_cc1 -triple riscv64-linux-gnu -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14 | ||
|
||
// expected-warning@+2 {{unsupported 'arch=rv64gcv' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=rv64gcv"))) int fullArchString(void) { return 2; } | ||
// expected-error@+2 {{redefinition of 'fullArchString'}} | ||
// expected-warning@+1 {{unsupported 'arch=default' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
__attribute__((target_version("arch=default"))) int fullArchString(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'mcpu=sifive-u74' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("mcpu=sifive-u74"))) int mcpu(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'mcpu'}} | ||
__attribute__((target_version("default"))) int mcpu(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'mtune=sifive-u74' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("mtune=sifive-u74"))) int mtune(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'mtune'}} | ||
__attribute__((target_version("default"))) int mtune(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version(""))) int emptyVersion(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'emptyVersion'}} | ||
__attribute__((target_version("default"))) int emptyVersion(void) { return 2; } | ||
|
||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=+c"))) int dupVersion(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'dupVersion'}} | ||
__attribute__((target_version("arch=+c"))) int dupVersion(void) { return 2; } | ||
__attribute__((target_version("default"))) int dupVersion(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'arch=+zicsr' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=+zicsr"))) int UnsupportBitMaskExt(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'UnsupportBitMaskExt'}} | ||
__attribute__((target_version("default"))) int UnsupportBitMaskExt(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'NotADigit' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=+c;priority=NotADigit"))) int UnsupportPriority(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'UnsupportPriority'}} | ||
__attribute__((target_version("default"))) int UnsupportPriority(void) { return 2;} | ||
|
||
// expected-warning@+1 {{unsupported 'default;priority=2' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
__attribute__((target_version("default;priority=2"))) int UnsupportDefaultPriority(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'arch=+c,zbb' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=+c,zbb"))) int WithoutAddSign(void) { return 2;} | ||
// expected-error@+1 {{redefinition of 'WithoutAddSign'}} | ||
__attribute__((target_version("default"))) int WithoutAddSign(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'arch=+c;default' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=+c;default"))) int DefaultInVersion(void) { return 2;} | ||
// expected-error@+1 {{redefinition of 'DefaultInVersion'}} | ||
__attribute__((target_version("default"))) int DefaultInVersion(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=+c;"))) int EmptyVersionAfterSemiColon(void) { return 2;} | ||
// expected-error@+1 {{redefinition of 'EmptyVersionAfterSemiColon'}} | ||
__attribute__((target_version("default"))) int EmptyVersionAfterSemiColon(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'arch=+c;arch=+f' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("arch=+c;arch=+f"))) int dupArch(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'dupArch'}} | ||
__attribute__((target_version("default"))) int dupArch(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'default;default' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("default;default"))) int dupDefault(void) { return 2;} | ||
// expected-error@+1 {{redefinition of 'dupDefault'}} | ||
__attribute__((target_version("default"))) int dupDefault(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'priority=1;priority=2' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("priority=1;priority=2"))) int dupPriority(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'dupPriority'}} | ||
__attribute__((target_version("default"))) int dupPriority(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported '=1' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("=1"))) int invalidVerson1(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'invalidVerson1'}} | ||
__attribute__((target_version("default"))) int invalidVerson1(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported '=+v' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("=+v"))) int invalidVerson2(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'invalidVerson2'}} | ||
__attribute__((target_version("default"))) int invalidVerson2(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'v' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("v"))) int invalidVerson3(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'invalidVerson3'}} | ||
__attribute__((target_version("default"))) int invalidVerson3(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported '' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version(";"))) int invalidVerson4(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'invalidVerson4'}} | ||
__attribute__((target_version("default"))) int invalidVerson4(void) { return 2; } | ||
|
||
// expected-warning@+2 {{unsupported 'priority=1' in the 'target_version' attribute string; 'target_version' attribute ignored}} | ||
// expected-note@+1 {{previous definition is here}} | ||
__attribute__((target_version("priority=1"))) int prioriyWithoutArch(void) { return 2; } | ||
// expected-error@+1 {{redefinition of 'prioriyWithoutArch'}} | ||
__attribute__((target_version("default"))) int prioriyWithoutArch(void) { return 2; } |