File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ use rustc_session::Session;
4444use rustc_smir:: rustc_internal;
4545use rustc_target:: abi:: Endian ;
4646use rustc_target:: spec:: PanicStrategy ;
47- use stable_mir:: mir:: mono:: MonoItem ;
47+ use stable_mir:: mir:: mono:: { Instance , MonoItem } ;
4848use stable_mir:: CrateDef ;
4949use std:: any:: Any ;
5050use std:: collections:: BTreeMap ;
@@ -281,10 +281,15 @@ impl CodegenBackend for GotocCodegenBackend {
281281 }
282282 ReachabilityType :: None => { }
283283 ReachabilityType :: PubFns => {
284- let local_reachable = filter_crate_items ( tcx, |_, _| true )
285- . into_iter ( )
286- . map ( MonoItem :: Fn )
287- . collect :: < Vec < _ > > ( ) ;
284+ let main_instance =
285+ stable_mir:: entry_fn ( ) . map ( |main_fn| Instance :: try_from ( main_fn) . unwrap ( ) ) ;
286+ let local_reachable = filter_crate_items ( tcx, |_, instance| {
287+ let def_id = rustc_internal:: internal ( instance. def . def_id ( ) ) ;
288+ Some ( instance) == main_instance || tcx. is_reachable_non_generic ( def_id)
289+ } )
290+ . into_iter ( )
291+ . map ( MonoItem :: Fn )
292+ . collect :: < Vec < _ > > ( ) ;
288293 let model_path = base_filename. with_extension ( ArtifactType :: SymTabGoto ) ;
289294 let ( gcx, items) = self . codegen_items (
290295 tcx,
Original file line number Diff line number Diff line change 7373 crate_items
7474 . iter ( )
7575 . filter_map ( |item| {
76- tracing:: warn!( ?item, name = item. name( ) , "crate_item" ) ;
77- tracing:: warn!( body=?item. body( ) . blocks. len( ) , "crate_item" ) ;
7876 // Only collect monomorphic items.
7977 // TODO: Remove the def_kind check once https://github.com/rust-lang/rust/pull/119135 has been released.
8078 let def_id = rustc_internal:: internal ( item. def_id ( ) ) ;
You can’t perform that action at this time.
0 commit comments