@@ -1898,7 +1898,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
1898
1898
1899
1899
let pt = * pt + [ path_name ( ccx. names ( name) ) ] ;
1900
1900
let s = mangle_exported_name ( ccx, pt, mono_ty) ;
1901
- let lldecl = decl_cdecl_fn ( ccx. llmod , s, llfty) ;
1901
+ let lldecl = decl_internal_cdecl_fn ( ccx. llmod , s, llfty) ;
1902
1902
ccx. monomorphized . insert ( hash_id, lldecl) ;
1903
1903
ccx. item_symbols . insert ( fn_id. node , s) ;
1904
1904
@@ -1982,12 +1982,14 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
1982
1982
}
1983
1983
csearch:: found ( ast:: ii_method ( impl_did, mth) ) {
1984
1984
ccx. external . insert ( fn_id, some ( mth. id ) ) ;
1985
- compute_ii_method_info ( ccx, impl_did, mth) { |ty, bounds, path|
1986
- if bounds. len ( ) == 0 u {
1987
- let llfn = get_item_val ( ccx, mth. id ) ;
1988
- trans_fn ( ccx, path, mth. decl , mth. body ,
1989
- llfn, impl_self ( ty) , none, mth. id , none) ;
1990
- }
1985
+ let { bounds: impl_bnds , ty: impl_ty} =
1986
+ ty:: lookup_item_type ( ccx. tcx , impl_did) ;
1987
+ if ( * impl_bnds) . len ( ) + mth. tps . len ( ) == 0 u {
1988
+ let llfn = get_item_val ( ccx, mth. id ) ;
1989
+ let path = ty:: item_path ( ccx. tcx , impl_did) +
1990
+ [ path_name ( mth. ident ) ] ;
1991
+ trans_fn ( ccx, path, mth. decl , mth. body ,
1992
+ llfn, impl_self ( impl_ty) , none, mth. id , none) ;
1991
1993
}
1992
1994
local_def ( mth. id )
1993
1995
}
@@ -4173,18 +4175,6 @@ fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) {
4173
4175
for item in m. items { trans_item ( ccx, * item) ; }
4174
4176
}
4175
4177
4176
- fn compute_ii_method_info ( ccx : @crate_ctxt ,
4177
- impl_did : ast:: def_id ,
4178
- m : @ast:: method ,
4179
- f : fn ( ty:: t , [ ty:: param_bounds ] , ast_map:: path ) ) {
4180
- let { bounds: impl_bnds , ty: impl_ty} =
4181
- ty:: lookup_item_type ( ccx. tcx , impl_did) ;
4182
- let m_bounds = * impl_bnds + param_bounds ( ccx, m. tps ) ;
4183
- let impl_path = ty:: item_path ( ccx. tcx , impl_did) ;
4184
- let m_path = impl_path + [ path_name ( m. ident ) ] ;
4185
- f ( impl_ty, m_bounds, m_path) ;
4186
- }
4187
-
4188
4178
fn get_pair_fn_ty ( llpairty : TypeRef ) -> TypeRef {
4189
4179
// Bit of a kludge: pick the fn typeref out of the pair.
4190
4180
ret struct_elt ( llpairty, 0 u) ;
@@ -4196,11 +4186,6 @@ fn register_fn(ccx: @crate_ctxt, sp: span, path: path, flav: str,
4196
4186
register_fn_full ( ccx, sp, path, flav, node_id, t)
4197
4187
}
4198
4188
4199
- fn param_bounds ( ccx : @crate_ctxt , tps : [ ast:: ty_param ] )
4200
- -> [ ty:: param_bounds ] {
4201
- vec:: map ( tps) { |tp| ccx. tcx . ty_param_bounds . get ( tp. id ) }
4202
- }
4203
-
4204
4189
fn register_fn_full ( ccx : @crate_ctxt , sp : span , path : path , flav : str ,
4205
4190
node_id : ast:: node_id , node_type : ty:: t ) -> ValueRef {
4206
4191
let llfty = type_of_fn_from_ty ( ccx, node_type) ;
@@ -4333,6 +4318,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
4333
4318
alt ccx. item_vals . find ( id) {
4334
4319
some ( v) { v }
4335
4320
none {
4321
+ let exprt = false ;
4336
4322
let val = alt check ccx. tcx . items . get ( id) {
4337
4323
ast_map:: node_item ( i, pth) {
4338
4324
let my_path = * pth + [ path_name ( i. ident ) ] ;
@@ -4368,6 +4354,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
4368
4354
}
4369
4355
}
4370
4356
ast_map:: node_method ( m, impl_id, pth) {
4357
+ exprt = true ;
4371
4358
let mty = ty:: node_id_to_type ( ccx. tcx , id) ;
4372
4359
let pth = * pth + [ path_name ( int:: str ( impl_id. node ) ) ,
4373
4360
path_name ( m. ident ) ] ;
@@ -4377,6 +4364,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
4377
4364
llfn
4378
4365
}
4379
4366
ast_map:: node_native_item ( ni, _, pth) {
4367
+ exprt = true ;
4380
4368
native:: decl_native_fn ( ccx, ni, * pth + [ path_name ( ni. ident ) ] )
4381
4369
}
4382
4370
ast_map:: node_ctor ( i, _) {
@@ -4405,6 +4393,9 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
4405
4393
llfn
4406
4394
}
4407
4395
} ;
4396
+ if !( exprt || ccx. reachable . contains_key ( id) ) {
4397
+ lib:: llvm:: SetLinkage ( val, lib:: llvm:: InternalLinkage ) ;
4398
+ }
4408
4399
ccx. item_vals . insert ( id, val) ;
4409
4400
val
4410
4401
}
0 commit comments