llvm-project/clang/test/Driver/aarch64-negative-modifiers-for-default-features.c
Tomas Matheson 362142c4bb
[AArch64] Add a check for invalid default features (#104435)
This adds a check that all ExtensionWithMArch which are marked as
implied features for an architecture are also present in the list of
default features. It doesn't make sense to have something mandatory but
not on by default.

There were a number of existing cases that violated this rule, and some
changes to which features are mandatory (indicated by the Implies
field).

This resulted in a bug where if a feature was marked as `Implies` but
was not added to `DefaultExt`, then for `-march=base_arch+nofeat` the
Driver would consider `feat` to have never been added and therefore
would do nothing to disable it (no `-target-feature -feat` would be
added, but the backend would enable the feature by default because of
`Implies`). See
clang/test/Driver/aarch64-negative-modifiers-for-default-features.c.

Note that the processor definitions do not respect the architecture
DefaultExts. These apply only when specifying `-march=<some architecture
version>`. So when a feature is moved from `Implies` to `DefaultExts` on
the Architecture definition, the feature needs to be added to all
processor definitions (that are based on that architecture) in order to
preserve the existing behaviour. I have checked the TRMs for many cases
(see specific commit messages) but in other cases I have just kept the
current behaviour and not tried to fix it.
2024-08-17 13:36:40 +01:00

13 lines
502 B
C

// Test that default features (e.g. flagm/sb/ssbs for 8.5) can be disabled via -march.
// RUN: %clang --target=aarch64 -march=armv8.5-a+noflagm+nosb+nossbs -c %s -### 2>&1 | FileCheck %s
// CHECK: "-triple" "aarch64"
// CHECK-SAME: "-target-feature" "+v8.5a"
// CHECK-SAME: "-target-feature" "-flagm"
// CHECK-SAME: "-target-feature" "-sb"
// CHECK-SAME: "-target-feature" "-ssbs"
// CHECK-NOT: "-target-feature" "+flagm"
// CHECK-NOT: "-target-feature" "+sb"
// CHECK-NOT: "-target-feature" "+ssbs"