@@ -34,10 +34,8 @@ use back::linker::LinkerInfo;
3434use back:: symbol_export:: { self , ExportedSymbols } ;
3535use llvm:: { Linkage , ValueRef , Vector , get_param} ;
3636use llvm;
37- use rustc:: hir:: def_id:: { DefId , LOCAL_CRATE } ;
37+ use rustc:: hir:: def_id:: LOCAL_CRATE ;
3838use middle:: lang_items:: StartFnLangItem ;
39- use rustc:: ty:: subst:: Substs ;
40- use rustc:: mir:: tcx:: LvalueTy ;
4139use rustc:: traits;
4240use rustc:: ty:: { self , Ty , TyCtxt } ;
4341use rustc:: ty:: adjustment:: CustomCoerceUnsized ;
@@ -47,9 +45,8 @@ use rustc::util::common::time;
4745use session:: config:: { self , NoDebugInfo } ;
4846use rustc_incremental:: IncrementalHashesMap ;
4947use session:: { self , DataTypeKind , Session } ;
50- use abi:: { self , FnType } ;
48+ use abi;
5149use mir:: lvalue:: LvalueRef ;
52- use adt;
5350use attributes;
5451use builder:: Builder ;
5552use callee:: { Callee } ;
@@ -65,7 +62,7 @@ use context::{SharedCrateContext, CrateContextList};
6562use debuginfo;
6663use declare;
6764use machine;
68- use machine:: { llalign_of_min , llsize_of} ;
65+ use machine:: llsize_of;
6966use meth;
7067use mir;
7168use monomorphize:: { self , Instance } ;
@@ -76,7 +73,6 @@ use trans_item::{TransItem, DefPathBasedNames};
7673use type_:: Type ;
7774use type_of;
7875use value:: Value ;
79- use Disr ;
8076use util:: nodemap:: { NodeSet , FxHashMap , FxHashSet } ;
8177
8278use libc:: c_uint;
@@ -615,72 +611,6 @@ pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance
615611 mir:: trans_mir ( ccx, lldecl, & mir, instance, sig) ;
616612}
617613
618- pub fn trans_ctor_shim < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
619- def_id : DefId ,
620- substs : & ' tcx Substs < ' tcx > ,
621- disr : Disr ,
622- llfn : ValueRef ) {
623- attributes:: inline ( llfn, attributes:: InlineAttr :: Hint ) ;
624- attributes:: set_frame_pointer_elimination ( ccx, llfn) ;
625-
626- let ctor_ty = common:: def_ty ( ccx. shared ( ) , def_id, substs) ;
627- let sig = ccx. tcx ( ) . erase_late_bound_regions_and_normalize ( & ctor_ty. fn_sig ( ) ) ;
628- let fn_ty = FnType :: new ( ccx, sig, & [ ] ) ;
629-
630- let bcx = Builder :: new_block ( ccx, llfn, "entry-block" ) ;
631- if !fn_ty. ret . is_ignore ( ) {
632- // But if there are no nested returns, we skip the indirection
633- // and have a single retslot
634- let dest = if fn_ty. ret . is_indirect ( ) {
635- get_param ( llfn, 0 )
636- } else {
637- // We create an alloca to hold a pointer of type `ret.original_ty`
638- // which will hold the pointer to the right alloca which has the
639- // final ret value
640- bcx. alloca ( fn_ty. ret . memory_ty ( ccx) , "sret_slot" )
641- } ;
642- // Can return unsized value
643- let mut dest_val = LvalueRef :: new_sized_ty ( dest, sig. output ( ) , Alignment :: AbiAligned ) ;
644- dest_val. ty = LvalueTy :: Downcast {
645- adt_def : sig. output ( ) . ty_adt_def ( ) . unwrap ( ) ,
646- substs : substs,
647- variant_index : disr. 0 as usize ,
648- } ;
649- let mut llarg_idx = fn_ty. ret . is_indirect ( ) as usize ;
650- let mut arg_idx = 0 ;
651- for ( i, arg_ty) in sig. inputs ( ) . iter ( ) . enumerate ( ) {
652- let ( lldestptr, _) = dest_val. trans_field_ptr ( & bcx, i) ;
653- let arg = & fn_ty. args [ arg_idx] ;
654- arg_idx += 1 ;
655- if common:: type_is_fat_ptr ( bcx. ccx , arg_ty) {
656- let meta = & fn_ty. args [ arg_idx] ;
657- arg_idx += 1 ;
658- arg. store_fn_arg ( & bcx, & mut llarg_idx, get_dataptr ( & bcx, lldestptr) ) ;
659- meta. store_fn_arg ( & bcx, & mut llarg_idx, get_meta ( & bcx, lldestptr) ) ;
660- } else {
661- arg. store_fn_arg ( & bcx, & mut llarg_idx, lldestptr) ;
662- }
663- }
664- adt:: trans_set_discr ( & bcx, sig. output ( ) , dest, disr) ;
665-
666- if fn_ty. ret . is_indirect ( ) {
667- bcx. ret_void ( ) ;
668- return ;
669- }
670-
671- if let Some ( cast_ty) = fn_ty. ret . cast {
672- bcx. ret ( bcx. load (
673- bcx. pointercast ( dest, cast_ty. ptr_to ( ) ) ,
674- Some ( llalign_of_min ( ccx, fn_ty. ret . ty ) )
675- ) ) ;
676- } else {
677- bcx. ret ( bcx. load ( dest, None ) )
678- }
679- } else {
680- bcx. ret_void ( ) ;
681- }
682- }
683-
684614pub fn llvm_linkage_by_name ( name : & str ) -> Option < Linkage > {
685615 // Use the names from src/llvm/docs/LangRef.rst here. Most types are only
686616 // applicable to variable declarations and may not really make sense for
@@ -721,7 +651,7 @@ pub fn set_link_section(ccx: &CrateContext,
721651}
722652
723653/// Create the `main` function which will initialise the rust runtime and call
724- /// users’ main function.
654+ /// users main function.
725655pub fn maybe_create_entry_wrapper ( ccx : & CrateContext ) {
726656 let ( main_def_id, span) = match * ccx. sess ( ) . entry_fn . borrow ( ) {
727657 Some ( ( id, span) ) => {
0 commit comments