@@ -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 funclet_bundle. is_some ( ) {
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 kcfi_bundle. is_some ( ) {
241+ bundles. push ( kcfi_bundle) ;
242+ }
237243
238- bundles. retain ( |bundle| bundle. is_some ( ) ) ;
239244 let invoke = unsafe {
240245 llvm:: LLVMRustBuildInvoke (
241246 self . llbuilder ,
@@ -1189,17 +1194,21 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11891194 let args = self . check_call ( "call" , llty, llfn, args) ;
11901195 let funclet_bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
11911196 let funclet_bundle = funclet_bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
1192- let mut bundles = vec ! [ funclet_bundle] ;
1197+ let mut bundles: SmallVec < [ _ ; 2 ] > = SmallVec :: new ( ) ;
1198+ if funclet_bundle. is_some ( ) {
1199+ bundles. push ( funclet_bundle) ;
1200+ }
11931201
11941202 // Emit CFI pointer type membership test
11951203 self . cfi_type_test ( fn_attrs, fn_abi, llfn) ;
11961204
11971205 // Emit KCFI operand bundle
11981206 let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, llfn) ;
11991207 let kcfi_bundle = kcfi_bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
1200- bundles. push ( kcfi_bundle) ;
1208+ if kcfi_bundle. is_some ( ) {
1209+ bundles. push ( kcfi_bundle) ;
1210+ }
12011211
1202- bundles. retain ( |bundle| bundle. is_some ( ) ) ;
12031212 let call = unsafe {
12041213 llvm:: LLVMRustBuildCall (
12051214 self . llbuilder ,
0 commit comments