@@ -23,6 +23,7 @@ use rustc_span::Span;
23
23
use rustc_symbol_mangling:: typeid:: { kcfi_typeid_for_fnabi, typeid_for_fnabi, TypeIdOptions } ;
24
24
use rustc_target:: abi:: { self , call:: FnAbi , Align , Size , WrappingRange } ;
25
25
use rustc_target:: spec:: { HasTargetSpec , SanitizerSet , Target } ;
26
+ use smallvec:: SmallVec ;
26
27
use std:: borrow:: Cow ;
27
28
use std:: iter;
28
29
use std:: ops:: Deref ;
@@ -225,17 +226,21 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
225
226
let args = self . check_call ( "invoke" , llty, llfn, args) ;
226
227
let funclet_bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
227
228
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
+ }
229
233
230
234
// Emit CFI pointer type membership test
231
235
self . cfi_type_test ( fn_attrs, fn_abi, llfn) ;
232
236
233
237
// Emit KCFI operand bundle
234
238
let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, llfn) ;
235
239
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
+ }
237
243
238
- bundles. retain ( |bundle| bundle. is_some ( ) ) ;
239
244
let invoke = unsafe {
240
245
llvm:: LLVMRustBuildInvoke (
241
246
self . llbuilder ,
@@ -1181,17 +1186,21 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1181
1186
let args = self . check_call ( "call" , llty, llfn, args) ;
1182
1187
let funclet_bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
1183
1188
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
+ }
1185
1193
1186
1194
// Emit CFI pointer type membership test
1187
1195
self . cfi_type_test ( fn_attrs, fn_abi, llfn) ;
1188
1196
1189
1197
// Emit KCFI operand bundle
1190
1198
let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, llfn) ;
1191
1199
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
+ }
1193
1203
1194
- bundles. retain ( |bundle| bundle. is_some ( ) ) ;
1195
1204
let call = unsafe {
1196
1205
llvm:: LLVMRustBuildCall (
1197
1206
self . llbuilder ,
0 commit comments