@@ -431,6 +431,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
431431 bundles. push ( kcfi_bundle) ;
432432 }
433433
434+ let pauth = self . ptrauth_operand_bundle ( llfn) ;
435+ if let Some ( p) = pauth. as_ref ( ) . map ( |b| b. as_ref ( ) ) {
436+ bundles. push ( p) ;
437+ }
438+
434439 let invoke = unsafe {
435440 llvm:: LLVMBuildInvokeWithOperandBundles (
436441 self . llbuilder ,
@@ -1417,6 +1422,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
14171422 bundles. push ( kcfi_bundle) ;
14181423 }
14191424
1425+ let pauth = self . ptrauth_operand_bundle ( llfn) ;
1426+ if let Some ( p) = pauth. as_ref ( ) . map ( |b| b. as_ref ( ) ) {
1427+ bundles. push ( p) ;
1428+ }
1429+
14201430 let call = unsafe {
14211431 llvm:: LLVMBuildCallWithOperandBundles (
14221432 self . llbuilder ,
@@ -1785,6 +1795,11 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17851795 if let Some ( kcfi_bundle) = kcfi_bundle. as_ref ( ) . map ( |b| b. as_ref ( ) ) {
17861796 bundles. push ( kcfi_bundle) ;
17871797 }
1798+
1799+ let pauth = self . ptrauth_operand_bundle ( llfn) ;
1800+ if let Some ( p) = pauth. as_ref ( ) . map ( |b| b. as_ref ( ) ) {
1801+ bundles. push ( p) ;
1802+ }
17881803
17891804 let callbr = unsafe {
17901805 llvm:: LLVMBuildCallBr (
@@ -1905,6 +1920,18 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
19051920 kcfi_bundle
19061921 }
19071922
1923+ fn ptrauth_operand_bundle ( & mut self , llfn : & ' ll Value )
1924+ -> Option < llvm:: OperandBundleBox < ' ll > >
1925+ {
1926+ let on_arm64e = self . cx . sess ( ) . target . llvm_target . starts_with ( "arm64e-apple-" ) ;
1927+ if !on_arm64e { return None ; }
1928+
1929+ let is_non_gv_fn_ptr = unsafe { llvm:: LLVMRustIsNonGVFunctionPointerTy ( llfn) } ;
1930+ if !is_non_gv_fn_ptr { return None ; }
1931+
1932+ Some ( llvm:: OperandBundleBox :: new ( "ptrauth" , & [ self . const_i32 ( 0 ) , self . const_u64 ( 0 ) ] ) )
1933+ }
1934+
19081935 /// Emits a call to `llvm.instrprof.increment`. Used by coverage instrumentation.
19091936 #[ instrument( level = "debug" , skip( self ) ) ]
19101937 pub ( crate ) fn instrprof_increment (
0 commit comments