llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[AArch64][Driver] +nofeat modifier on -mcpu is ineffective when feat is an implied mandatory feature

Open ytmukai opened this issue 7 months ago • 3 comments

After the fix in #78270, there are cases where the +nofeat modifier on -mcpu has no effect. For example, Neoverse V2 does not directly enable FEAT_SB in its definition, but the feature is automatically implied because it is mandatory in Armv9. For such features, specifying -mcpu=neoverse-v2+nosb fails to disable FEAT_SB.

Reproducer: https://godbolt.org/z/48Y7dbKeP

Before #78270, "-target-feature" "-sb" was emitted, but after the patch it is no longer emitted.

The following code ignores a +nofeat modifier when the feature was not enabled in the first place. It appears that mandatory features implied by the base architecture are not included in the default feature set.

https://github.com/llvm/llvm-project/blob/c9f09d305b555d0312cc76e665ba919be2d78236/llvm/lib/TargetParser/AArch64TargetParser.cpp#L329-L330

Should the fix either include such implied mandatory features in the defaults, or always pass through a negative feature when the user explicitly specifies +nofeat?

ytmukai avatar Apr 15 '26 05:04 ytmukai

@llvm/issue-subscribers-backend-aarch64

Author: Yuta Mukai (ytmukai)

After the fix in #78270, there are cases where the +nofeat modifier on -mcpu has no effect. For example, Neoverse V2 does not directly enable FEAT_SB in [its definition](https://github.com/llvm/llvm-project/blob/c9f09d305b555d0312cc76e665ba919be2d78236/llvm/lib/Target/AArch64/AArch64Processors.td#L1314), but the feature is automatically implied because it is mandatory in Armv9. For such features, specifying `-mcpu=neoverse-v2+nosb` fails to disable FEAT_SB.

Reproducer: https://godbolt.org/z/48Y7dbKeP

Before #78270, "-target-feature" "-sb" was emitted, but after the patch it is no longer emitted.

The following code ignores a +nofeat modifier when the feature was not enabled in the first place. It appears that mandatory features implied by the base architecture are not included in the default feature set.

https://github.com/llvm/llvm-project/blob/c9f09d305b555d0312cc76e665ba919be2d78236/llvm/lib/TargetParser/AArch64TargetParser.cpp#L329-L330

Should the fix either include such implied mandatory features in the defaults, or always pass through a negative feature when the user explicitly specifies +nofeat?

llvmbot avatar Apr 15 '26 05:04 llvmbot

@llvm/issue-subscribers-clang-driver

Author: Yuta Mukai (ytmukai)

After the fix in #78270, there are cases where the +nofeat modifier on -mcpu has no effect. For example, Neoverse V2 does not directly enable FEAT_SB in [its definition](https://github.com/llvm/llvm-project/blob/c9f09d305b555d0312cc76e665ba919be2d78236/llvm/lib/Target/AArch64/AArch64Processors.td#L1314), but the feature is automatically implied because it is mandatory in Armv9. For such features, specifying `-mcpu=neoverse-v2+nosb` fails to disable FEAT_SB.

Reproducer: https://godbolt.org/z/48Y7dbKeP

Before #78270, "-target-feature" "-sb" was emitted, but after the patch it is no longer emitted.

The following code ignores a +nofeat modifier when the feature was not enabled in the first place. It appears that mandatory features implied by the base architecture are not included in the default feature set.

https://github.com/llvm/llvm-project/blob/c9f09d305b555d0312cc76e665ba919be2d78236/llvm/lib/TargetParser/AArch64TargetParser.cpp#L329-L330

Should the fix either include such implied mandatory features in the defaults, or always pass through a negative feature when the user explicitly specifies +nofeat?

llvmbot avatar Apr 15 '26 05:04 llvmbot

Hi, I'm working on this issue. Could you assign it to me?

yamash-fj avatar Jun 03 '26 00:06 yamash-fj