@@ -411,26 +411,31 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
411
411
// the string "false". Now it is disabled by absence of the attribute.
412
412
to_add. push ( llvm:: CreateAttrStringValue ( cx. llcx , "branch-target-enforcement" , "false" ) ) ;
413
413
}
414
- } else if llvm_util:: get_version ( ) >= ( 19 , 0 , 0 ) {
415
- // For non-naked functions, set branch protection attributes on aarch64.
416
- if let Some ( BranchProtection { bti, pac_ret } ) =
417
- cx. sess ( ) . opts . unstable_opts . branch_protection
418
- {
419
- assert ! ( cx. sess( ) . target. arch == "aarch64" ) ;
420
- if bti {
421
- to_add. push ( llvm:: CreateAttrString ( cx. llcx , "branch-target-enforcement" ) ) ;
422
- }
423
- if let Some ( PacRet { leaf, key } ) = pac_ret {
424
- to_add. push ( llvm:: CreateAttrStringValue (
425
- cx. llcx ,
426
- "sign-return-address" ,
427
- if leaf { "all" } else { "non-leaf" } ,
428
- ) ) ;
429
- to_add. push ( llvm:: CreateAttrStringValue (
430
- cx. llcx ,
431
- "sign-return-address-key" ,
432
- if key == PAuthKey :: A { "a_key" } else { "b_key" } ,
433
- ) ) ;
414
+ } else {
415
+ // Do not set sanitizer attributes for naked functions.
416
+ to_add. extend ( sanitize_attrs ( cx, codegen_fn_attrs. no_sanitize ) ) ;
417
+
418
+ if llvm_util:: get_version ( ) >= ( 19 , 0 , 0 ) {
419
+ // For non-naked functions, set branch protection attributes on aarch64.
420
+ if let Some ( BranchProtection { bti, pac_ret } ) =
421
+ cx. sess ( ) . opts . unstable_opts . branch_protection
422
+ {
423
+ assert ! ( cx. sess( ) . target. arch == "aarch64" ) ;
424
+ if bti {
425
+ to_add. push ( llvm:: CreateAttrString ( cx. llcx , "branch-target-enforcement" ) ) ;
426
+ }
427
+ if let Some ( PacRet { leaf, key } ) = pac_ret {
428
+ to_add. push ( llvm:: CreateAttrStringValue (
429
+ cx. llcx ,
430
+ "sign-return-address" ,
431
+ if leaf { "all" } else { "non-leaf" } ,
432
+ ) ) ;
433
+ to_add. push ( llvm:: CreateAttrStringValue (
434
+ cx. llcx ,
435
+ "sign-return-address-key" ,
436
+ if key == PAuthKey :: A { "a_key" } else { "b_key" } ,
437
+ ) ) ;
438
+ }
434
439
}
435
440
}
436
441
}
@@ -485,7 +490,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
485
490
if let Some ( backchain) = backchain_attr ( cx) {
486
491
to_add. push ( backchain) ;
487
492
}
488
- to_add. extend ( sanitize_attrs ( cx, codegen_fn_attrs. no_sanitize ) ) ;
489
493
to_add. extend ( patchable_function_entry_attrs ( cx, codegen_fn_attrs. patchable_function_entry ) ) ;
490
494
491
495
// Always annotate functions with the target-cpu they are compiled for.
0 commit comments