@@ -166,7 +166,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
166
166
bx. invoke ( fn_ty, fn_ptr, & llargs, ret_llbb, unwind_block, self . funclet ( fx) ) ;
167
167
bx. apply_attrs_callsite ( & fn_abi, invokeret) ;
168
168
if fx. mir [ self . bb ] . is_cleanup {
169
- bx. apply_attrs_to_cleanup_callsite ( invokeret) ;
169
+ bx. do_not_inline ( invokeret) ;
170
170
}
171
171
172
172
if let Some ( ( ret_dest, target) ) = destination {
@@ -178,7 +178,11 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
178
178
let llret = bx. call ( fn_ty, fn_ptr, & llargs, self . funclet ( fx) ) ;
179
179
bx. apply_attrs_callsite ( & fn_abi, llret) ;
180
180
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) ;
182
186
}
183
187
184
188
if let Some ( ( ret_dest, target) ) = destination {
@@ -1444,7 +1448,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1444
1448
1445
1449
let llret = bx. call ( fn_ty, fn_ptr, & [ ] , None ) ;
1446
1450
bx. apply_attrs_callsite ( & fn_abi, llret) ;
1447
- bx. apply_attrs_to_cleanup_callsite ( llret) ;
1451
+ bx. do_not_inline ( llret) ;
1448
1452
1449
1453
bx. unreachable ( ) ;
1450
1454
0 commit comments