@@ -1777,6 +1777,25 @@ fn get_static_tydesc(&@block_ctxt cx,
1777
1777
}
1778
1778
}
1779
1779
1780
+ fn set_no_inline( ValueRef f) {
1781
+ llvm:: LLVMAddFunctionAttr ( f, lib:: llvm:: LLVMNoInlineAttribute as
1782
+ lib:: llvm:: llvm:: Attribute ) ;
1783
+ }
1784
+
1785
+ fn set_always_inline( ValueRef f) {
1786
+ llvm:: LLVMAddFunctionAttr ( f, lib:: llvm:: LLVMAlwaysInlineAttribute as
1787
+ lib:: llvm:: llvm:: Attribute ) ;
1788
+ }
1789
+
1790
+ fn set_glue_inlining( & @local_ctxt cx, ValueRef f, & ty:: t t) {
1791
+ if ( ty:: type_is_structural( cx. ccx. tcx, t) ) {
1792
+ set_no_inline( f) ;
1793
+ } else {
1794
+ set_always_inline( f) ;
1795
+ }
1796
+ }
1797
+
1798
+
1780
1799
// Generates the declaration for (but doesn't emit) a type descriptor.
1781
1800
fn declare_tydesc( & @local_ctxt cx, & ast:: span sp, & ty:: t t,
1782
1801
vec[ uint] ty_params) -> @tydesc_info {
@@ -1838,6 +1857,7 @@ fn declare_generic_glue(&@local_ctxt cx,
1838
1857
fn_nm = mangle_name_by_seq( cx. ccx, cx. path, "glue_" + name) ;
1839
1858
}
1840
1859
auto llfn = decl_fastcall_fn( cx. ccx. llmod, fn_nm, llfnty) ;
1860
+ set_glue_inlining( cx, llfn, t) ;
1841
1861
ret llfn;
1842
1862
}
1843
1863
@@ -2916,10 +2936,6 @@ fn lazily_emit_tydesc_glue(&@block_ctxt cx, int field,
2916
2936
declare_generic_glue( lcx, ti. ty,
2917
2937
T_glue_fn ( lcx. ccx. tn) ,
2918
2938
"free") ;
2919
- // Don't inline free glue; it's cold.
2920
- llvm:: LLVMAddFunctionAttr ( glue_fn,
2921
- lib:: llvm:: LLVMNoInlineAttribute as
2922
- lib:: llvm:: llvm:: Attribute ) ;
2923
2939
2924
2940
ti. free_glue = some[ ValueRef ] ( glue_fn) ;
2925
2941
auto dg = make_free_glue;
@@ -2976,10 +2992,10 @@ fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v,
2976
2992
}
2977
2993
2978
2994
fn call_tydesc_glue( & @block_ctxt cx, ValueRef v,
2979
- & ty:: t t, bool escapes , int field) -> result {
2995
+ & ty:: t t, int field) -> result {
2980
2996
2981
2997
let option:: t[ @tydesc_info] ti = none[ @tydesc_info] ;
2982
- auto td = get_tydesc( cx, t, escapes , ti) ;
2998
+ auto td = get_tydesc( cx, t, false , ti) ;
2983
2999
2984
3000
call_tydesc_glue_full( td. bcx,
2985
3001
spill_if_immediate( td. bcx, v, t) ,
@@ -3054,7 +3070,7 @@ fn call_cmp_glue(&@block_ctxt cx,
3054
3070
3055
3071
fn take_ty( & @block_ctxt cx, ValueRef v, ty:: t t) -> result {
3056
3072
if ( ty:: type_has_pointers( cx. fcx. lcx. ccx. tcx, t) ) {
3057
- ret call_tydesc_glue( cx, v, t, false , abi:: tydesc_field_take_glue) ;
3073
+ ret call_tydesc_glue( cx, v, t, abi:: tydesc_field_take_glue) ;
3058
3074
}
3059
3075
ret res( cx, C_nil ( ) ) ;
3060
3076
}
@@ -3076,7 +3092,7 @@ fn drop_ty(&@block_ctxt cx,
3076
3092
ty:: t t) -> result {
3077
3093
3078
3094
if ( ty:: type_has_pointers( cx. fcx. lcx. ccx. tcx, t) ) {
3079
- ret call_tydesc_glue( cx, v, t, false , abi:: tydesc_field_drop_glue) ;
3095
+ ret call_tydesc_glue( cx, v, t, abi:: tydesc_field_drop_glue) ;
3080
3096
}
3081
3097
ret res( cx, C_nil ( ) ) ;
3082
3098
}
@@ -3086,7 +3102,7 @@ fn free_ty(&@block_ctxt cx,
3086
3102
ty:: t t) -> result {
3087
3103
3088
3104
if ( ty:: type_has_pointers( cx. fcx. lcx. ccx. tcx, t) ) {
3089
- ret call_tydesc_glue( cx, v, t, false , abi:: tydesc_field_free_glue) ;
3105
+ ret call_tydesc_glue( cx, v, t, abi:: tydesc_field_free_glue) ;
3090
3106
}
3091
3107
ret res( cx, C_nil ( ) ) ;
3092
3108
}
0 commit comments