@@ -24,6 +24,7 @@ use rustc_span::Span;
24
24
use rustc_symbol_mangling:: typeid:: { kcfi_typeid_for_fnabi, typeid_for_fnabi, TypeIdOptions } ;
25
25
use rustc_target:: abi:: { self , call:: FnAbi , Align , Size , WrappingRange } ;
26
26
use rustc_target:: spec:: { HasTargetSpec , SanitizerSet , Target } ;
27
+ use smallvec:: SmallVec ;
27
28
use std:: borrow:: Cow ;
28
29
use std:: ffi:: CStr ;
29
30
use std:: iter;
@@ -1229,9 +1230,19 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1229
1230
unsafe { llvm:: LLVMBuildZExt ( self . llbuilder , val, dest_ty, UNNAMED ) }
1230
1231
}
1231
1232
1232
- fn do_not_inline ( & mut self , llret : & ' ll Value ) {
1233
- let noinline = llvm:: AttributeKind :: NoInline . create_attr ( self . llcx ) ;
1234
- attributes:: apply_to_callsite ( llret, llvm:: AttributePlace :: Function , & [ noinline] ) ;
1233
+ fn apply_attrs_to_cleanup_callsite ( & mut self , llret : & ' ll Value ) {
1234
+ let mut attrs = SmallVec :: < [ _ ; 2 ] > :: new ( ) ;
1235
+
1236
+ // Cleanup is always the cold path.
1237
+ attrs. push ( llvm:: AttributeKind :: Cold . create_attr ( self . llcx ) ) ;
1238
+
1239
+ // In LLVM versions with deferred inlining (currently, system LLVM < 14),
1240
+ // inlining drop glue can lead to exponential size blowup, see #41696 and #92110.
1241
+ if !llvm_util:: is_rust_llvm ( ) && llvm_util:: get_version ( ) < ( 14 , 0 , 0 ) {
1242
+ attrs. push ( llvm:: AttributeKind :: NoInline . create_attr ( self . llcx ) ) ;
1243
+ }
1244
+
1245
+ attributes:: apply_to_callsite ( llret, llvm:: AttributePlace :: Function , & attrs) ;
1235
1246
}
1236
1247
}
1237
1248
0 commit comments