@@ -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 funclet_bundle. is_some ( ) {
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 kcfi_bundle. is_some ( ) {
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 ,
@@ -1189,17 +1194,21 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1189
1194
let args = self . check_call ( "call" , llty, llfn, args) ;
1190
1195
let funclet_bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
1191
1196
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
+ }
1193
1201
1194
1202
// Emit CFI pointer type membership test
1195
1203
self . cfi_type_test ( fn_attrs, fn_abi, llfn) ;
1196
1204
1197
1205
// Emit KCFI operand bundle
1198
1206
let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, llfn) ;
1199
1207
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
+ }
1201
1211
1202
- bundles. retain ( |bundle| bundle. is_some ( ) ) ;
1203
1212
let call = unsafe {
1204
1213
llvm:: LLVMRustBuildCall (
1205
1214
self . llbuilder ,
0 commit comments