@@ -192,22 +192,6 @@ impl<'a, 'tcx> Drop for StatRecorder<'a, 'tcx> {
192
192
}
193
193
}
194
194
195
- fn get_extern_rust_fn < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
196
- fn_ty : Ty < ' tcx > ,
197
- name : & str ,
198
- attrs : & [ ast:: Attribute ] )
199
- -> ValueRef {
200
- if let Some ( n) = ccx. externs ( ) . borrow ( ) . get ( name) {
201
- return * n;
202
- }
203
-
204
- let f = declare:: declare_rust_fn ( ccx, name, fn_ty) ;
205
- attributes:: from_fn_attrs ( ccx, & attrs, f) ;
206
-
207
- ccx. externs ( ) . borrow_mut ( ) . insert ( name. to_string ( ) , f) ;
208
- f
209
- }
210
-
211
195
pub fn self_type_for_closure < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
212
196
closure_id : DefId ,
213
197
fn_ty : Ty < ' tcx > )
@@ -865,34 +849,6 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
865
849
}
866
850
}
867
851
868
- pub fn get_extern_fn < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
869
- def_id : DefId )
870
- -> datum:: Datum < ' tcx , datum:: Rvalue > {
871
- let name = ccx. sess ( ) . cstore . item_symbol ( def_id) ;
872
- let attrs = ccx. sess ( ) . cstore . item_attrs ( def_id) ;
873
- let ty = ccx. tcx ( ) . lookup_item_type ( def_id) . ty ;
874
- match ty. sty {
875
- ty:: TyFnDef ( _, _, fty) => {
876
- let abi = fty. abi ;
877
- let fty = infer:: normalize_associated_type ( ccx. tcx ( ) , fty) ;
878
- let ty = ccx. tcx ( ) . mk_fn_ptr ( fty) ;
879
- let llfn = match ccx. sess ( ) . target . target . adjust_abi ( abi) {
880
- Abi :: RustIntrinsic | Abi :: PlatformIntrinsic => {
881
- ccx. sess ( ) . bug ( "unexpected intrinsic in get_extern_fn" )
882
- }
883
- Abi :: Rust | Abi :: RustCall => {
884
- get_extern_rust_fn ( ccx, ty, & name, & attrs)
885
- }
886
- _ => {
887
- foreign:: register_foreign_item_fn ( ccx, abi, ty, & name, & attrs)
888
- }
889
- } ;
890
- datum:: immediate_rvalue ( llfn, ty)
891
- }
892
- _ => unreachable ! ( "get_extern_fn: expected fn item type, found {}" , ty)
893
- }
894
- }
895
-
896
852
pub fn invoke < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
897
853
llfn : ValueRef ,
898
854
llargs : & [ ValueRef ] ,
@@ -2186,20 +2142,11 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
2186
2142
Result :: new ( bcx, llresult)
2187
2143
}
2188
2144
2189
- pub fn trans_tuple_struct < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
2190
- ctor_id : ast:: NodeId ,
2191
- param_substs : & ' tcx Substs < ' tcx > ,
2192
- llfndecl : ValueRef ) {
2193
- let _icx = push_ctxt ( "trans_tuple_struct" ) ;
2194
-
2195
- trans_enum_variant_or_tuple_like_struct ( ccx, ctor_id, Disr ( 0 ) , param_substs, llfndecl) ;
2196
- }
2197
-
2198
- fn trans_enum_variant_or_tuple_like_struct < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
2199
- ctor_id : ast:: NodeId ,
2200
- disr : Disr ,
2201
- param_substs : & ' tcx Substs < ' tcx > ,
2202
- llfndecl : ValueRef ) {
2145
+ pub fn trans_ctor_shim < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
2146
+ ctor_id : ast:: NodeId ,
2147
+ disr : Disr ,
2148
+ param_substs : & ' tcx Substs < ' tcx > ,
2149
+ llfndecl : ValueRef ) {
2203
2150
let ctor_ty = ccx. tcx ( ) . node_id_to_type ( ctor_id) ;
2204
2151
let ctor_ty = monomorphize:: apply_param_substs ( ccx. tcx ( ) , param_substs, & ctor_ty) ;
2205
2152
@@ -2557,54 +2504,6 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
2557
2504
}
2558
2505
}
2559
2506
2560
- // only use this for foreign function ABIs and glue, use `register_fn` for Rust functions
2561
- pub fn register_fn_llvmty ( ccx : & CrateContext ,
2562
- sp : Span ,
2563
- sym : String ,
2564
- node_id : ast:: NodeId ,
2565
- cc : llvm:: CallConv ,
2566
- llfty : Type )
2567
- -> ValueRef {
2568
- debug ! ( "register_fn_llvmty id={} sym={}" , node_id, sym) ;
2569
-
2570
- let llfn = declare:: define_fn ( ccx, & sym[ ..] , cc, llfty,
2571
- ty:: FnConverging ( ccx. tcx ( ) . mk_nil ( ) ) ) . unwrap_or_else ( ||{
2572
- ccx. sess ( ) . span_fatal ( sp, & format ! ( "symbol `{}` is already defined" , sym) ) ;
2573
- } ) ;
2574
- finish_register_fn ( ccx, sym, node_id) ;
2575
- llfn
2576
- }
2577
-
2578
- fn finish_register_fn ( ccx : & CrateContext , sym : String , node_id : ast:: NodeId ) {
2579
- ccx. item_symbols ( ) . borrow_mut ( ) . insert ( node_id, sym) ;
2580
- }
2581
-
2582
- fn register_fn < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
2583
- sp : Span ,
2584
- sym : String ,
2585
- node_id : ast:: NodeId ,
2586
- node_type : Ty < ' tcx > )
2587
- -> ValueRef {
2588
- if let ty:: TyFnDef ( _, _, ref f) = node_type. sty {
2589
- if f. abi != Abi :: Rust && f. abi != Abi :: RustCall {
2590
- ccx. sess ( ) . span_bug ( sp,
2591
- & format ! ( "only the `{}` or `{}` calling conventions are valid \
2592
- for this function; `{}` was specified",
2593
- Abi :: Rust . name( ) ,
2594
- Abi :: RustCall . name( ) ,
2595
- f. abi. name( ) ) ) ;
2596
- }
2597
- } else {
2598
- ccx. sess ( ) . span_bug ( sp, "expected bare rust function" )
2599
- }
2600
-
2601
- let llfn = declare:: define_rust_fn ( ccx, & sym[ ..] , node_type) . unwrap_or_else ( || {
2602
- ccx. sess ( ) . span_fatal ( sp, & format ! ( "symbol `{}` is already defined" , sym) ) ;
2603
- } ) ;
2604
- finish_register_fn ( ccx, sym, node_id) ;
2605
- llfn
2606
- }
2607
-
2608
2507
pub fn is_entry_fn ( sess : & Session , node_id : ast:: NodeId ) -> bool {
2609
2508
match * sess. entry_fn . borrow ( ) {
2610
2509
Some ( ( entry_id, _) ) => node_id == entry_id,
@@ -2724,119 +2623,6 @@ fn contains_null(s: &str) -> bool {
2724
2623
s. bytes ( ) . any ( |b| b == 0 )
2725
2624
}
2726
2625
2727
- pub fn get_item_val ( ccx : & CrateContext , id : ast:: NodeId ) -> ValueRef {
2728
- debug ! ( "get_item_val(id=`{}`)" , id) ;
2729
-
2730
- if let Some ( v) = ccx. item_vals ( ) . borrow ( ) . get ( & id) . cloned ( ) {
2731
- return v;
2732
- }
2733
-
2734
- let item = ccx. tcx ( ) . map . get ( id) ;
2735
- debug ! ( "get_item_val: id={} item={:?}" , id, item) ;
2736
- let val = match item {
2737
- hir_map:: NodeItem ( i) => {
2738
- let ty = ccx. tcx ( ) . node_id_to_type ( i. id ) ;
2739
- let sym = || exported_name ( ccx, id, ty, & i. attrs ) ;
2740
-
2741
- let v = match i. node {
2742
-
2743
- hir:: ItemFn ( _, _, _, abi, _, _) => {
2744
- let sym = sym ( ) ;
2745
- let llfn = if abi == Abi :: Rust {
2746
- register_fn ( ccx, i. span , sym, i. id , ty)
2747
- } else {
2748
- foreign:: register_rust_fn_with_foreign_abi ( ccx, i. span , sym, i. id )
2749
- } ;
2750
- attributes:: from_fn_attrs ( ccx, & i. attrs , llfn) ;
2751
- llfn
2752
- }
2753
-
2754
- _ => ccx. sess ( ) . bug ( "get_item_val: weird result in table" ) ,
2755
- } ;
2756
-
2757
- v
2758
- }
2759
-
2760
- hir_map:: NodeTraitItem ( trait_item) => {
2761
- debug ! ( "get_item_val(): processing a NodeTraitItem" ) ;
2762
- match trait_item. node {
2763
- hir:: MethodTraitItem ( _, Some ( _) ) => {
2764
- register_method ( ccx, id, & trait_item. attrs , trait_item. span )
2765
- }
2766
- _ => {
2767
- ccx. sess ( ) . span_bug ( trait_item. span ,
2768
- "unexpected variant: trait item other than a provided \
2769
- method in get_item_val()") ;
2770
- }
2771
- }
2772
- }
2773
-
2774
- hir_map:: NodeImplItem ( impl_item) => {
2775
- match impl_item. node {
2776
- hir:: ImplItemKind :: Method ( ..) => {
2777
- register_method ( ccx, id, & impl_item. attrs , impl_item. span )
2778
- }
2779
- _ => {
2780
- ccx. sess ( ) . span_bug ( impl_item. span ,
2781
- "unexpected variant: non-method impl item in \
2782
- get_item_val()") ;
2783
- }
2784
- }
2785
- }
2786
-
2787
- hir_map:: NodeForeignItem ( ni) => {
2788
- match ni. node {
2789
- hir:: ForeignItemFn ( ..) => {
2790
- let abi = ccx. tcx ( ) . map . get_foreign_abi ( id) ;
2791
- let ty = ccx. tcx ( ) . node_id_to_type ( ni. id ) ;
2792
- let name = foreign:: link_name ( & ni) ;
2793
- foreign:: register_foreign_item_fn ( ccx, abi, ty, & name, & ni. attrs )
2794
- }
2795
- hir:: ForeignItemStatic ( ..) => {
2796
- foreign:: register_static ( ccx, & ni)
2797
- }
2798
- }
2799
- }
2800
- ref variant => {
2801
- ccx. sess ( ) . bug ( & format ! ( "get_item_val(): unexpected variant: {:?}" , variant) )
2802
- }
2803
- } ;
2804
-
2805
- // All LLVM globals and functions are initially created as external-linkage
2806
- // declarations. If `trans_item`/`trans_fn` later turns the declaration
2807
- // into a definition, it adjusts the linkage then (using `update_linkage`).
2808
- //
2809
- // The exception is foreign items, which have their linkage set inside the
2810
- // call to `foreign::register_*` above. We don't touch the linkage after
2811
- // that (`foreign::trans_foreign_mod` doesn't adjust the linkage like the
2812
- // other item translation functions do).
2813
-
2814
- ccx. item_vals ( ) . borrow_mut ( ) . insert ( id, val) ;
2815
- val
2816
- }
2817
-
2818
- fn register_method ( ccx : & CrateContext ,
2819
- id : ast:: NodeId ,
2820
- attrs : & [ ast:: Attribute ] ,
2821
- span : Span )
2822
- -> ValueRef {
2823
- let mty = ccx. tcx ( ) . node_id_to_type ( id) ;
2824
-
2825
- let sym = exported_name ( ccx, id, mty, & attrs) ;
2826
-
2827
- if let ty:: TyFnDef ( _, _, ref f) = mty. sty {
2828
- let llfn = if f. abi == Abi :: Rust || f. abi == Abi :: RustCall {
2829
- register_fn ( ccx, span, sym, id, mty)
2830
- } else {
2831
- foreign:: register_rust_fn_with_foreign_abi ( ccx, span, sym, id)
2832
- } ;
2833
- attributes:: from_fn_attrs ( ccx, & attrs, llfn) ;
2834
- return llfn;
2835
- } else {
2836
- ccx. sess ( ) . span_bug ( span, "expected bare rust function" ) ;
2837
- }
2838
- }
2839
-
2840
2626
pub fn write_metadata < ' a , ' tcx > ( cx : & SharedCrateContext < ' a , ' tcx > ,
2841
2627
krate : & hir:: Crate ,
2842
2628
reachable : & NodeSet ,
0 commit comments