-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Illegal instructions generated for Arm Cortex-R5 processor when compiling code using floating-point operations #128448
Comments
As mentioned on the thread, this seems to come from LLVM. Would you mind filing an issue there? Here is an llc reproduction that shows |
Whoops, didn't mean to remove prioritize but I think the labels raced. |
cc @chrisnc as the maintainer for this target. We updated the float support in #123159 to be more-correct for this target but it looks like we didn't quite stick the landing I guess?
We most definitely intentionally included the R5 here, though apparently we assume an R5F. |
LLVM's policy for Arm |
https://godbolt.org/z/cj38s8Ev6 This will also disable the floating-point support. I think the issue is that the implied |
Thanks a lot @chrisnc for investigating this issue!
Yes, right now that seems the clearest approach. There's the downside that Or should the non-
Should I still go ahead and file an issue with LLVM as suggested initially by @tgross35? One source of confusion for me is that LLVM seems to distinguish between Cortex-R4 and Cortex-R4F, but not between Cortex-R5 and Cortex-R5F. |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
I don't think there's a way to disable this right now except to use nightly. I can't find an open issue for stabilizing these right now, but that is the path. This warning is relatively recent, and this issue gives some explanation of why it's there: #117616.
The
I think that would be worthwhile, at least to understand why there is a separate |
We should probably just add this feature. |
@chrisnc For note, LLVM seems to have flipflopped on the maximal vs. minimal thing for Arm CPUs at least twice now, and recent Arm CPUs (aarch64, mostly) are more likely to use a minimal featureset, though that may only be true from Armv9 onwards. |
Whoops, I missed that this was also unknown, not just unstable, when I wrote my comment. I'm not sure this will be possible though, because it affects the ABI, and the reasoning here applies to Arm also. Should
Interesting... At least for the v7m, v7r, v8m, and v8r cores, the default feature sets have all been maximal when each core was added and then not changed except for refactoring and bug fixes from what I can see, but A-profile and Aarch64 are quite a bit more varied and may have different considerations. It seems that R4 as distinct from R4F was done originally in GCC in 2008 and then LLVM followed it, but no other exceptions exist, even though "M4F" and "R5F" and others are commonly mentioned when a non-trivial population of them are |
When targeting the Arm Cortex-R5 processor, rustc and llvm generate assembly containing floating-point instructions. These are not available on the Cortex-R5 (only on the Cortex-R5F) and cause the processor to halt.
Details
For example, the following code:
compiled with flags
--target armv7r-none-eabi -C opt-level=3 -C target-cpu=cortex-r5
generates the assembly (compiler explorer link):Note the
vadd.f32
andvadd.f64
instructions, that are available on the Cortex-R5F which has an FPU, but that are illegal instructions on the Cortex-R5 without an FPU.My expectation is that, using the target
armv7r-none-eabi
(rather thanarmv7r-none-eabihf
) and the target CPUcortex-r5
(rather thancortex-r5f
), rustc and llvm would generate legal instructions for the processor, i.e. use software floating-point features rather than hard-float instructions.Relevant information
Original thread on URLO: Unexpected codegen for Cortex-R5 without FPU.
The upstream LLVM CPU model for cortex-r5 includes the flag FeatureVFP3_D16, which seems OK for the R5F but wrong for the R5. However, manually disabling that feature doesn't seem to help (see below). Link to llvm repo at tag 18.1.7.
Information from the ARM Cortex-R Series Programmer's Guide: 6.1.6. VFP in the Cortex-R processors.
Things that do work
Skipping the target-cpu flag
Compiling the snippet above with flags
--target armv7r-none-eabi -C opt-level=3
generates:Adding the soft-float target feature
Compiling the snippet above with flags
--target armv7r-none-eabi -C opt-level=3 -C target-cpu=cortex-r5 -C target-feature=+soft-float
generates:However, rustc generates the warning:
Things that don't work
Removing the vfp3d16 target feature
Compiling the snippet above with flags
--target armv7r-none-eabi -C opt-level=3 -C target-cpu=cortex-r5 -C target-feature=-vfp3d16
generates:Meta
I've tested both stable and nightly toolchains, with same results.
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: