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
This makes it impossible to use with SAW's mir_unsafe_assume_spec command. We should at least emit something for extern functions, even though they have no bodies.
Debugging notes: If you call my_c_function from another function, e.g.,
Then compiling it with mir-jsonstill won't give you something that can be looked up with mir_unsafe_assume_spec, since there won't be an entry for my_c_function in fns. There will, on the other hand, be some information related to my_c_function in the MIR JSON file:
This is better than nothing, but ultimately, mir_unsafe_assume_spec needs to be able to look up a function's type signature, which isn't easily accessible with this information alone. Question: should we put extern functions in fns (with no body), or should we put them in an entirely separate part of the MIR JSON file?
Note that unlike bugs such as #57, this one is not caused by missing a case in init_instances_from_tests, as that function only considers things that mir_keys() returns. Mostly, these are things with bodies of some sort, and as far as I can tell, this entirely excludes extern functions. In order to include extern functions in the MIR JSON, we will likely need to use a different rustc_middle API function to query them—foreign_modules(), perhaps?
The text was updated successfully, but these errors were encountered:
Question: should we put extern functions in fns (with no body), or should we put them in an entirely separate part of the MIR JSON file?
Looking at the current json format for fns, the name, return_ty, and abi fields all apply to extern fns, args partially applies (it has the argument types, but also details like name and mutability that aren't relevant to callers), and body and spread_arg don't apply. If we do end up adding a separate extern_fns table to the JSON format, it might be a good idea to extract all the caller-relevant info (arg types, return_ty, abi, and maybe spread_arg) into a common "fn sig" object that has the same format in both fns and extern_fns.
that function only considers things that mir_keys() returns. Mostly, these are things with bodies of some sort, and as far as I can tell, this entirely excludes extern functions
Right - extern fns have no executable rust code, so no MIR and no "MIR key".
order to include extern functions in the MIR JSON, we will likely need to use a different rustc_middle API function to query them—foreign_modules(), perhaps?
That would work. Another option would be to refactor init_instances_from_tests to explicitly visit every item in the crate with something like TyCtxt::hir_crate_items, which would make it clearer which defs we do and don't export, as opposed to the current approach that implicitly relies on some knowledge about which kinds of items have MIR.
If you compile an
extern
function withmir-json
, e.g.,Then it will not appear in the resulting MIR JSON file:
This makes it impossible to use with SAW's
mir_unsafe_assume_spec
command. We should at least emit something forextern
functions, even though they have no bodies.Debugging notes: If you call
my_c_function
from another function, e.g.,Then compiling it with
mir-json
still won't give you something that can be looked up withmir_unsafe_assume_spec
, since there won't be an entry formy_c_function
infns
. There will, on the other hand, be some information related tomy_c_function
in the MIR JSON file:This is better than nothing, but ultimately,
mir_unsafe_assume_spec
needs to be able to look up a function's type signature, which isn't easily accessible with this information alone. Question: should we putextern
functions infns
(with nobody
), or should we put them in an entirely separate part of the MIR JSON file?Note that unlike bugs such as #57, this one is not caused by missing a case in
init_instances_from_tests
, as that function only considers things thatmir_keys()
returns. Mostly, these are things with bodies of some sort, and as far as I can tell, this entirely excludesextern
functions. In order to includeextern
functions in the MIR JSON, we will likely need to use a differentrustc_middle
API function to query them—foreign_modules()
, perhaps?The text was updated successfully, but these errors were encountered: