You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code of closure_sig is copy-pasted from fn_sig_for_fn_abi in compiler/rustc_middle/src/ty/layout.rs. We may have to do something similar for generators (#416), so it would be good if we could use the rustc function fn_abi_of_instance directly (as the comment on fn_sig_for_fn_abi suggests. This would prevent problems with keeping in sync with rustc.
The relevant function fn_sig_for_fn_abi is here. It has a comment saying:
// NOTE(eddyb) this is private to avoid using it from outside of// `fn_abi_of_instance` - any other uses are either too high-level// for `Instance` (e.g. typeck would use `Ty::fn_sig` instead),// or should go through `FnAbi` instead, to avoid losing any// adjustments `fn_abi_of_instance` might be performing.
So the question is whether we should use Ty::fn_sig or fn_abi_of_instance. To find out, I looked at the cranelift backend. They use this function to obtain the signature of a function/closure/generator. I presume we should do something similar.
Note that the fn_abi_of_instance function makes some adjustments to the signature returned by the private function fn_sig_for_fn_abi: they happen in the call to fn_abi_new_uncachedhere, in that function they call fn_abi_adjust_for_abihere, which is defined just below.
@celinval The adjustments to the signature could be related to #1350. These adjustments don't currently happen in the Kani code, but they probably should.
Totally! We should investigate if using fn_abi_of_instance would simplify how we handle functions today. I believe this is also related to the issue we were having with closure to function pointer casting: #274
For the ZST parameters, the parameter "mode" is set to Ignore.
@celinval The adjustments to the signature could be related to #1350. These adjustments don't currently happen in the Kani code, but they probably should.
I don't think this would actually fix #1350 though. I believe we add those functions to the symbol table and their signature matches CBMC ones.
Activity
fzaiser commentedon Jul 29, 2022
The relevant function
fn_sig_for_fn_abiis here. It has a comment saying:So the question is whether we should use
Ty::fn_sigorfn_abi_of_instance. To find out, I looked at the cranelift backend. They use this function to obtain the signature of a function/closure/generator. I presume we should do something similar.Note that the
fn_abi_of_instancefunction makes some adjustments to the signature returned by the private functionfn_sig_for_fn_abi: they happen in the call tofn_abi_new_uncachedhere, in that function they callfn_abi_adjust_for_abihere, which is defined just below.fzaiser commentedon Jul 29, 2022
@celinval The adjustments to the signature could be related to #1350. These adjustments don't currently happen in the Kani code, but they probably should.
[-]Cleanup function signature codegen[/-][+]Audit function signature codegen[/+]celinval commentedon Jan 16, 2023
Totally! We should investigate if using
fn_abi_of_instancewould simplify how we handle functions today. I believe this is also related to the issue we were having with closure to function pointer casting: #274For the ZST parameters, the parameter "mode" is set to Ignore.
celinval commentedon May 2, 2023
I don't think this would actually fix #1350 though. I believe we add those functions to the symbol table and their signature matches CBMC ones.
FYI, we declare these functions and their signatures here: https://github.com/model-checking/kani/blob/main/cprover_bindings/src/goto_program/builtin.rs
celinval commentedon Jul 3, 2023
Note that the function ABI will include the tracker location when required, so #374 and this issue are somewhat related.
Migrate function, block and statement modules to StableMIR (#2947)
Fix ICEs due to mismatched arguments (model-checking#2994)