@@ -1512,9 +1512,9 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1512
1512
fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
1513
1513
llfn : & ' ll Value ,
1514
1514
) {
1515
- let is_indirect_call = unsafe { llvm:: LLVMIsAFunction ( llfn) . is_none ( ) } ;
1516
- if is_indirect_call && fn_abi . is_some ( ) && self . tcx . sess . is_sanitizer_cfi_enabled ( ) {
1517
- if fn_attrs . is_some ( ) && fn_attrs. unwrap ( ) . no_sanitize . contains ( SanitizerSet :: CFI ) {
1515
+ let is_indirect_call = unsafe { llvm:: LLVMRustIsNonGVFunctionPointerTy ( llfn) } ;
1516
+ if self . tcx . sess . is_sanitizer_cfi_enabled ( ) && let Some ( fn_abi ) = fn_abi && is_indirect_call {
1517
+ if let Some ( fn_attrs ) = fn_attrs && fn_attrs. no_sanitize . contains ( SanitizerSet :: CFI ) {
1518
1518
return ;
1519
1519
}
1520
1520
@@ -1526,7 +1526,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1526
1526
options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
1527
1527
}
1528
1528
1529
- let typeid = typeid_for_fnabi ( self . tcx , fn_abi. unwrap ( ) , options) ;
1529
+ let typeid = typeid_for_fnabi ( self . tcx , fn_abi, options) ;
1530
1530
let typeid_metadata = self . cx . typeid_metadata ( typeid) . unwrap ( ) ;
1531
1531
1532
1532
// Test whether the function pointer is associated with the type identifier.
@@ -1550,25 +1550,26 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1550
1550
fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
1551
1551
llfn : & ' ll Value ,
1552
1552
) -> Option < llvm:: OperandBundleDef < ' ll > > {
1553
- let is_indirect_call = unsafe { llvm:: LLVMIsAFunction ( llfn) . is_none ( ) } ;
1554
- let kcfi_bundle = if is_indirect_call && self . tcx . sess . is_sanitizer_kcfi_enabled ( ) {
1555
- if fn_attrs. is_some ( ) && fn_attrs. unwrap ( ) . no_sanitize . contains ( SanitizerSet :: KCFI ) {
1556
- return None ;
1557
- }
1553
+ let is_indirect_call = unsafe { llvm:: LLVMRustIsNonGVFunctionPointerTy ( llfn) } ;
1554
+ let kcfi_bundle =
1555
+ if self . tcx . sess . is_sanitizer_kcfi_enabled ( ) && let Some ( fn_abi) = fn_abi && is_indirect_call {
1556
+ if let Some ( fn_attrs) = fn_attrs && fn_attrs. no_sanitize . contains ( SanitizerSet :: KCFI ) {
1557
+ return None ;
1558
+ }
1558
1559
1559
- let mut options = TypeIdOptions :: empty ( ) ;
1560
- if self . tcx . sess . is_sanitizer_cfi_generalize_pointers_enabled ( ) {
1561
- options. insert ( TypeIdOptions :: GENERALIZE_POINTERS ) ;
1562
- }
1563
- if self . tcx . sess . is_sanitizer_cfi_normalize_integers_enabled ( ) {
1564
- options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
1565
- }
1560
+ let mut options = TypeIdOptions :: empty ( ) ;
1561
+ if self . tcx . sess . is_sanitizer_cfi_generalize_pointers_enabled ( ) {
1562
+ options. insert ( TypeIdOptions :: GENERALIZE_POINTERS ) ;
1563
+ }
1564
+ if self . tcx . sess . is_sanitizer_cfi_normalize_integers_enabled ( ) {
1565
+ options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
1566
+ }
1566
1567
1567
- let kcfi_typeid = kcfi_typeid_for_fnabi ( self . tcx , fn_abi. unwrap ( ) , options) ;
1568
- Some ( llvm:: OperandBundleDef :: new ( "kcfi" , & [ self . const_u32 ( kcfi_typeid) ] ) )
1569
- } else {
1570
- None
1571
- } ;
1568
+ let kcfi_typeid = kcfi_typeid_for_fnabi ( self . tcx , fn_abi, options) ;
1569
+ Some ( llvm:: OperandBundleDef :: new ( "kcfi" , & [ self . const_u32 ( kcfi_typeid) ] ) )
1570
+ } else {
1571
+ None
1572
+ } ;
1572
1573
kcfi_bundle
1573
1574
}
1574
1575
}
0 commit comments