@@ -166,7 +166,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
166166 bx. invoke ( fn_ty, fn_ptr, & llargs, ret_llbb, unwind_block, self . funclet ( fx) ) ;
167167 bx. apply_attrs_callsite ( & fn_abi, invokeret) ;
168168 if fx. mir [ self . bb ] . is_cleanup {
169- bx. apply_attrs_to_cleanup_callsite ( invokeret) ;
169+ bx. do_not_inline ( invokeret) ;
170170 }
171171
172172 if let Some ( ( ret_dest, target) ) = destination {
@@ -178,7 +178,11 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
178178 let llret = bx. call ( fn_ty, fn_ptr, & llargs, self . funclet ( fx) ) ;
179179 bx. apply_attrs_callsite ( & fn_abi, llret) ;
180180 if fx. mir [ self . bb ] . is_cleanup {
181- bx. apply_attrs_to_cleanup_callsite ( llret) ;
181+ // Cleanup is always the cold path. Don't inline
182+ // drop glue. Also, when there is a deeply-nested
183+ // struct, there are "symmetry" issues that cause
184+ // exponential inlining - see issue #41696.
185+ bx. do_not_inline ( llret) ;
182186 }
183187
184188 if let Some ( ( ret_dest, target) ) = destination {
@@ -1444,7 +1448,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14441448
14451449 let llret = bx. call ( fn_ty, fn_ptr, & [ ] , None ) ;
14461450 bx. apply_attrs_callsite ( & fn_abi, llret) ;
1447- bx. apply_attrs_to_cleanup_callsite ( llret) ;
1451+ bx. do_not_inline ( llret) ;
14481452
14491453 bx. unreachable ( ) ;
14501454
0 commit comments