@@ -1512,9 +1512,9 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15121512 fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
15131513 llfn : & ' ll Value ,
15141514 ) {
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 ) {
15181518 return ;
15191519 }
15201520
@@ -1526,7 +1526,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15261526 options. insert ( TypeIdOptions :: NORMALIZE_INTEGERS ) ;
15271527 }
15281528
1529- let typeid = typeid_for_fnabi ( self . tcx , fn_abi. unwrap ( ) , options) ;
1529+ let typeid = typeid_for_fnabi ( self . tcx , fn_abi, options) ;
15301530 let typeid_metadata = self . cx . typeid_metadata ( typeid) . unwrap ( ) ;
15311531
15321532 // Test whether the function pointer is associated with the type identifier.
@@ -1550,25 +1550,26 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15501550 fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
15511551 llfn : & ' ll Value ,
15521552 ) -> 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+ }
15581559
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+ }
15661567
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+ } ;
15721573 kcfi_bundle
15731574 }
15741575}
0 commit comments