-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
C-cmse-nonsecure-call
: improved error messages
#127814
C-cmse-nonsecure-call
: improved error messages
#127814
Conversation
when the `C-cmse-nonsecure-call` ABI is used, arguments and return values must be passed via registers. Failing to do so (i.e. spilling to the stack) causes an LLVM error down the line, but now rustc will properly emit an error a bit earlier in the chain
Some changes occurred in diagnostic error codes |
C-cmse-nonsecure-call
: improved error messages
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.
Diagnostic error explanation looks good to me.
Can you swap the commits so we can see the diagnostics as a diff on your actual commit? Or are the LLVM diagnostics too annoying? |
We did consider this, but LLVM will only return the first error it encounters. Also rebasing this is not straight forward, since we moved some of the tests which |
This comment has been minimized.
This comment has been minimized.
the error is only generated for functions that are actually codegen'd
Co-authored-by: Tamme Dittrich <tamme@tweedegolf.com>
For the name of the new |
/// Check conditions on inputs and outputs that the cmse ABIs impose: arguments and results MUST be | ||
/// returned via registers (i.e. MUST NOT spill to the stack). LLVM will also validate these | ||
/// conditions, but by checking them here rustc can emit nicer error messages. | ||
pub fn validate_cmse_abi<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( |
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.
in the near future, this will also validate the C-cmse-nonsecure-entry
abi which will be added by #127766.
This comment has been minimized.
This comment has been minimized.
CI fails with
How can I run those tests locally? EDIT: |
tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr
Outdated
Show resolved
Hide resolved
Something that stops working with the logic as implemented (and I think that is correct) is using a https://godbolt.org/z/oaTdf9cYE My reasoning is that |
HIR ty lowering was modified cc @fmease |
we've now implemented the logic in hir_analyze, removed code from codegen_ssa, and error when generics are used in function pointer types with the |
This comment has been minimized.
This comment has been minimized.
it was moved to hir_analysis in the previous commit
096cc19
to
6b6b842
Compare
@rustbot ready |
let mut accum = 0u64; | ||
|
||
for arg_def in fn_sig.inputs().iter() { | ||
for (index, arg_def) in fn_sig.inputs().iter().enumerate() { | ||
let layout = tcx.layout_of(ParamEnv::reveal_all().and(*arg_def.skip_binder()))?; |
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.
I think at this point it may be easier to just emit the errors in is_valid_cmse_inputs
and _output
directly. Then you can also report a "generics not allowed" error with a span pointing at the offending thing.
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.
we have 2 reasons not to do that
arg_def
doesn't have any span information. it's effectively just aTy
- in the (near, hopefully) future, the
C-cmse-nonsecure-entry
abi will require the same validation, and we'd like to reuse this code, so passing inBareFn
-specific data will not work
@bors r+ rollup |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#127295 (CFI: Support provided methods on traits) - rust-lang#127814 (`C-cmse-nonsecure-call`: improved error messages) - rust-lang#127949 (fix: explain E0120 better cover cases when its raised) - rust-lang#127966 (Use structured suggestions for unconstrained generic parameters on impl blocks) - rust-lang#127976 (Lazy type aliases: Diagostics: Detect bivariant ty params that are only used recursively) - rust-lang#127978 (Avoid ref when using format! for perf) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#127814 - folkertdev:c-cmse-nonsecure-call-error-messages, r=oli-obk `C-cmse-nonsecure-call`: improved error messages tracking issue: rust-lang#81391 issue for the error messages (partially implemented by this PR): rust-lang#81347 related, in that it also deals with CMSE: rust-lang#127766 When using the `C-cmse-nonsecure-call` ABI, both the arguments and return value must be passed via registers. Previously, when violating this constraint, an ugly LLVM error would be shown. Now, the rust compiler itself will print a pretty message and link to more information.
tracking issue: #81391
issue for the error messages (partially implemented by this PR): #81347
related, in that it also deals with CMSE: #127766
When using the
C-cmse-nonsecure-call
ABI, both the arguments and return value must be passed via registers. Previously, when violating this constraint, an ugly LLVM error would be shown. Now, the rust compiler itself will print a pretty message and link to more information.