File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44//! This file contains the code necessary to interface with the compiler backend
55
6- use crate :: overrides:: skip_monomorphize;
76use crate :: GotocCtx ;
7+
88use bitflags:: _core:: any:: Any ;
99use cbmc:: goto_program:: symtab_transformer;
1010use cbmc:: goto_program:: SymbolTable ;
@@ -46,9 +46,7 @@ impl CodegenBackend for GotocCodegenBackend {
4646 Box :: new ( rustc_codegen_ssa:: back:: metadata:: DefaultMetadataLoader )
4747 }
4848
49- fn provide ( & self , providers : & mut Providers ) {
50- providers. skip_monomorphize = skip_monomorphize;
51- }
49+ fn provide ( & self , _providers : & mut Providers ) { }
5250
5351 fn provide_extern ( & self , _providers : & mut ty:: query:: ExternProviders ) { }
5452
Original file line number Diff line number Diff line change @@ -326,6 +326,7 @@ struct MemSwap;
326326
327327impl < ' tcx > GotocHook < ' tcx > for MemSwap {
328328 fn hook_applies ( & self , tcx : TyCtxt < ' tcx > , instance : Instance < ' tcx > ) -> bool {
329+ // We need to keep the old std / core functions here because we don't compile std yet.
329330 let name = with_no_trimmed_paths ( || tcx. def_path_str ( instance. def_id ( ) ) ) ;
330331 name == "core::mem::swap"
331332 || name == "std::mem::swap"
@@ -688,7 +689,3 @@ impl<'tcx> GotocHooks<'tcx> {
688689 None
689690 }
690691}
691-
692- pub fn skip_monomorphize < ' tcx > ( tcx : TyCtxt < ' tcx > , instance : Instance < ' tcx > ) -> bool {
693- fn_hooks ( ) . hooks . iter ( ) . any ( |hook| hook. hook_applies ( tcx, instance) )
694- }
Original file line number Diff line number Diff line change 88
99mod hooks;
1010
11- pub use hooks:: { fn_hooks, skip_monomorphize , GotocHooks } ;
11+ pub use hooks:: { fn_hooks, GotocHooks } ;
Original file line number Diff line number Diff line change @@ -874,7 +874,6 @@ impl CrateInfo {
874874}
875875
876876pub fn provide ( providers : & mut Providers ) {
877- providers. skip_monomorphize = |_, _| false ;
878877 providers. backend_optimization_level = |tcx, cratenum| {
879878 let for_speed = match tcx. sess . opts . optimize {
880879 // If globally no optimisation is done, #[optimize] has no effect.
Original file line number Diff line number Diff line change @@ -1862,11 +1862,4 @@ rustc_queries! {
18621862 no_hash
18631863 desc { "performing HIR wf-checking for predicate {:?} at item {:?}" , key. 0 , key. 1 }
18641864 }
1865-
1866- query skip_monomorphize( key: ty:: Instance <' tcx>)
1867- -> bool {
1868- eval_always
1869- no_hash
1870- desc { "Check if we should skip monomorphization for `{}`" , key}
1871- }
18721865}
Original file line number Diff line number Diff line change @@ -317,7 +317,6 @@ pub fn collect_crate_mono_items(
317317 ( visited. into_inner ( ) , inlining_map. into_inner ( ) )
318318}
319319
320- // Temporary function that allow us to skip monomorphizing lang_start.
321320// Find all non-generic items by walking the HIR. These items serve as roots to
322321// start monomorphizing from.
323322fn collect_roots ( tcx : TyCtxt < ' _ > , mode : MonoItemCollectionMode ) -> Vec < MonoItem < ' _ > > {
@@ -922,10 +921,6 @@ fn visit_instance_use<'tcx>(
922921 return ;
923922 }
924923
925- if tcx. skip_monomorphize ( instance) {
926- return ;
927- }
928-
929924 match instance. def {
930925 ty:: InstanceDef :: Virtual ( ..) | ty:: InstanceDef :: Intrinsic ( _) => {
931926 if !is_direct_call {
Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+ use std:: mem;
5+
6+ pub fn main ( ) {
7+ let mut var1 = rmc:: nondet :: < i32 > ( ) ;
8+ let mut var2 = rmc:: nondet :: < i32 > ( ) ;
9+ let old_var1 = var1;
10+ unsafe {
11+ assert_eq ! ( mem:: replace( & mut var1, var2) , old_var1) ;
12+ }
13+ assert_eq ! ( var1, var2) ;
14+ }
Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+ use std:: mem;
5+
6+ pub fn main ( ) {
7+ let mut var1 = rmc:: nondet :: < i32 > ( ) ;
8+ let mut var2 = rmc:: nondet :: < i32 > ( ) ;
9+ let old_var1 = var1;
10+ let old_var2 = var2;
11+ unsafe {
12+ mem:: swap ( & mut var1, & mut var2) ;
13+ }
14+ assert_eq ! ( var1, old_var2) ;
15+ assert_eq ! ( var2, old_var1) ;
16+ }
Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+ use std:: ptr:: read;
5+
6+ pub fn main ( ) {
7+ let var = 1 ;
8+ unsafe {
9+ assert_eq ! ( read( & var) , var) ;
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+ use std:: ptr:: write;
5+
6+ pub fn main ( ) {
7+ let mut var = 1 ;
8+ unsafe {
9+ write ( & mut var, 10 ) ;
10+ }
11+ assert_eq ! ( var, 10 ) ;
12+ }
You can’t perform that action at this time.
0 commit comments