@@ -1525,9 +1525,9 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1525
1525
fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
1526
1526
llfn : & ' ll Value ,
1527
1527
) {
1528
- let is_indirect_call = unsafe { llvm:: LLVMIsAFunction ( llfn) . is_none ( ) } ;
1529
- if is_indirect_call && fn_abi . is_some ( ) && self . tcx . sess . is_sanitizer_cfi_enabled ( ) {
1530
- if fn_attrs . is_some ( ) && fn_attrs. unwrap ( ) . no_sanitize . contains ( SanitizerSet :: CFI ) {
1528
+ let is_indirect_call = unsafe { llvm:: LLVMRustIsNonGVFunctionPointerTy ( llfn) } ;
1529
+ if self . tcx . sess . is_sanitizer_cfi_enabled ( ) && let Some ( fn_abi ) = fn_abi && is_indirect_call {
1530
+ if let Some ( fn_attrs ) = fn_attrs && fn_attrs. no_sanitize . contains ( SanitizerSet :: CFI ) {
1531
1531
return ;
1532
1532
}
1533
1533
@@ -1539,7 +1539,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1539
1539
options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
1540
1540
}
1541
1541
1542
- let typeid = typeid_for_fnabi ( self . tcx , fn_abi. unwrap ( ) , options) ;
1542
+ let typeid = typeid_for_fnabi ( self . tcx , fn_abi, options) ;
1543
1543
let typeid_metadata = self . cx . typeid_metadata ( typeid) . unwrap ( ) ;
1544
1544
1545
1545
// Test whether the function pointer is associated with the type identifier.
@@ -1563,25 +1563,26 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1563
1563
fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
1564
1564
llfn : & ' ll Value ,
1565
1565
) -> Option < llvm:: OperandBundleDef < ' ll > > {
1566
- let is_indirect_call = unsafe { llvm:: LLVMIsAFunction ( llfn) . is_none ( ) } ;
1567
- let kcfi_bundle = if is_indirect_call && self . tcx . sess . is_sanitizer_kcfi_enabled ( ) {
1568
- if fn_attrs. is_some ( ) && fn_attrs. unwrap ( ) . no_sanitize . contains ( SanitizerSet :: KCFI ) {
1569
- return None ;
1570
- }
1566
+ let is_indirect_call = unsafe { llvm:: LLVMRustIsNonGVFunctionPointerTy ( llfn) } ;
1567
+ let kcfi_bundle =
1568
+ if self . tcx . sess . is_sanitizer_kcfi_enabled ( ) && let Some ( fn_abi) = fn_abi && is_indirect_call {
1569
+ if let Some ( fn_attrs) = fn_attrs && fn_attrs. no_sanitize . contains ( SanitizerSet :: KCFI ) {
1570
+ return None ;
1571
+ }
1571
1572
1572
- let mut options = TypeIdOptions :: empty ( ) ;
1573
- if self . tcx . sess . is_sanitizer_cfi_generalize_pointers_enabled ( ) {
1574
- options. insert ( TypeIdOptions :: GENERALIZE_POINTERS ) ;
1575
- }
1576
- if self . tcx . sess . is_sanitizer_cfi_normalize_integers_enabled ( ) {
1577
- options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
1578
- }
1573
+ let mut options = TypeIdOptions :: empty ( ) ;
1574
+ if self . tcx . sess . is_sanitizer_cfi_generalize_pointers_enabled ( ) {
1575
+ options. insert ( TypeIdOptions :: GENERALIZE_POINTERS ) ;
1576
+ }
1577
+ if self . tcx . sess . is_sanitizer_cfi_normalize_integers_enabled ( ) {
1578
+ options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
1579
+ }
1579
1580
1580
- let kcfi_typeid = kcfi_typeid_for_fnabi ( self . tcx , fn_abi. unwrap ( ) , options) ;
1581
- Some ( llvm:: OperandBundleDef :: new ( "kcfi" , & [ self . const_u32 ( kcfi_typeid) ] ) )
1582
- } else {
1583
- None
1584
- } ;
1581
+ let kcfi_typeid = kcfi_typeid_for_fnabi ( self . tcx , fn_abi, options) ;
1582
+ Some ( llvm:: OperandBundleDef :: new ( "kcfi" , & [ self . const_u32 ( kcfi_typeid) ] ) )
1583
+ } else {
1584
+ None
1585
+ } ;
1585
1586
kcfi_bundle
1586
1587
}
1587
1588
}
0 commit comments