-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AArch64TargetParser]Fix reconstructFromParsedFeatures ignoring negative features #142236
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
Changes from all commits
92da4de
34d6e7f
1a9f8a3
650461d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // RUN: %clang_cc1 -triple aarch64-- -target-feature +neon -target-feature +sve\ | ||
| // RUN: -target-feature -sve -emit-llvm %s -o - | FileCheck %s | ||
|
|
||
| // Reproducer for bug where clang would reject always_inline for unrelated | ||
| // target features if they were disable with `-feature` on the command line. | ||
| // CHECK: @bar | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to check the LLVM IR |
||
| __attribute__((always_inline)) __attribute__((target("neon"))) void foo() {} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-march
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true, but the header shouldn't be doing that.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That said, since the header does use it we should check that it behaves sensibly. |
||
| void bar() { foo(); } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1831,6 +1831,22 @@ TEST_P(AArch64ExtensionDependenciesBaseCPUTestFixture, | |
| } | ||
| } | ||
|
|
||
| TEST(TargetParserTest, testAArch64ReconstructFromParsedFeatures) { | ||
MatzeB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| AArch64::ExtensionSet Extensions; | ||
| std::vector<std::string> FeatureOptions = { | ||
| "-sve2", "-Baz", "+sve", "+FooBar", "+sve2", "+neon", "-sve", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this has the same issue as described for the C test: the function is not designed to be able to handle both
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line made me believe it was meant to handle negative features: https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/AArch64TargetParser.cpp#L368
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the original intention was for it to be able to handle either positive (added to the |
||
| }; | ||
| std::vector<std::string> NonExtensions; | ||
| Extensions.reconstructFromParsedFeatures(FeatureOptions, NonExtensions); | ||
|
|
||
| std::vector<std::string> NonExtensionsExpected = {"-Baz", "+FooBar"}; | ||
| ASSERT_THAT(NonExtensions, testing::ContainerEq(NonExtensionsExpected)); | ||
| std::vector<StringRef> Features; | ||
| Extensions.toLLVMFeatureList(Features); | ||
| std::vector<StringRef> FeaturesExpected = {"+neon", "-sve", "+sve2"}; | ||
labrinea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ASSERT_THAT(Features, testing::ContainerEq(FeaturesExpected)); | ||
| } | ||
|
|
||
| AArch64ExtensionDependenciesBaseArchTestParams | ||
| AArch64ExtensionDependenciesArchData[] = { | ||
| // Base architecture features | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver should never emit a
-cc1command line with-target-feature +sve -target-feature -sve, so I don't think this is a valid way to test whatever the problem is.