@@ -23,6 +23,7 @@ use rustc_span::Span;
2323use rustc_symbol_mangling:: typeid:: { kcfi_typeid_for_fnabi, typeid_for_fnabi, TypeIdOptions } ;
2424use rustc_target:: abi:: { self , call:: FnAbi , Align , Size , WrappingRange } ;
2525use rustc_target:: spec:: { HasTargetSpec , SanitizerSet , Target } ;
26+ use smallvec:: SmallVec ;
2627use std:: borrow:: Cow ;
2728use std:: iter;
2829use std:: ops:: Deref ;
@@ -225,17 +226,21 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
225226 let args = self . check_call ( "invoke" , llty, llfn, args) ;
226227 let funclet_bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
227228 let funclet_bundle = funclet_bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
228- let mut bundles = vec ! [ funclet_bundle] ;
229+ let mut bundles: SmallVec < [ _ ; 2 ] > = SmallVec :: new ( ) ;
230+ if let Some ( funclet_bundle) = funclet_bundle {
231+ bundles. push ( funclet_bundle) ;
232+ }
229233
230234 // Emit CFI pointer type membership test
231235 self . cfi_type_test ( fn_attrs, fn_abi, llfn) ;
232236
233237 // Emit KCFI operand bundle
234238 let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, llfn) ;
235239 let kcfi_bundle = kcfi_bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
236- bundles. push ( kcfi_bundle) ;
240+ if let Some ( kcfi_bundle) = kcfi_bundle {
241+ bundles. push ( kcfi_bundle) ;
242+ }
237243
238- bundles. retain ( |bundle| bundle. is_some ( ) ) ;
239244 let invoke = unsafe {
240245 llvm:: LLVMRustBuildInvoke (
241246 self . llbuilder ,
@@ -1181,17 +1186,21 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11811186 let args = self . check_call ( "call" , llty, llfn, args) ;
11821187 let funclet_bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
11831188 let funclet_bundle = funclet_bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
1184- let mut bundles = vec ! [ funclet_bundle] ;
1189+ let mut bundles: SmallVec < [ _ ; 2 ] > = SmallVec :: new ( ) ;
1190+ if let Some ( funclet_bundle) = funclet_bundle {
1191+ bundles. push ( funclet_bundle) ;
1192+ }
11851193
11861194 // Emit CFI pointer type membership test
11871195 self . cfi_type_test ( fn_attrs, fn_abi, llfn) ;
11881196
11891197 // Emit KCFI operand bundle
11901198 let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, llfn) ;
11911199 let kcfi_bundle = kcfi_bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
1192- bundles. push ( kcfi_bundle) ;
1200+ if let Some ( kcfi_bundle) = kcfi_bundle {
1201+ bundles. push ( kcfi_bundle) ;
1202+ }
11931203
1194- bundles. retain ( |bundle| bundle. is_some ( ) ) ;
11951204 let call = unsafe {
11961205 llvm:: LLVMRustBuildCall (
11971206 self . llbuilder ,
0 commit comments