
So far branch protection, sign return address, guarded control stack attributes are only emitted as module flags to indicate the functions need to be generated with those features. The problem is in case of an LTO build the module flags are merged with the `min` rule which means if one of the module is not build with sign return address then the features will be turned off for all functions. Due to the functions take the branch-protection and sign-return-address features from the module flags. The sign-return-address is function level option therefore it is expected functions from files that is compiled with -mbranch-protection=pac-ret to be protected. The inliner might inline functions with different set of flags as it doesn't consider the module flags. This patch adds the attributes to all functions and drops the checking of the module flags for the code generation. Module flag is still used for generating the ELF markers. Also drops the "true"/"false" values from the branch-protection-enforcement, branch-protection-pauth-lr, guarded-control-stack attributes as presence of the attribute means it is on absence means off and no other option. Releand with test fixes.
64 lines
1.8 KiB
LLVM
64 lines
1.8 KiB
LLVM
; RUN: llc < %s -mtriple=aarch64-windows | FileCheck %s
|
|
|
|
define dso_local i32 @func(ptr %g, i32 %a) "sign-return-address"="non-leaf" "sign-return-address-key"="b_key" {
|
|
entry:
|
|
tail call void %g() #2
|
|
ret i32 %a
|
|
}
|
|
|
|
define dso_local i32 @func2(ptr %g, i32 %a) "sign-return-address"="non-leaf" "sign-return-address-key"="b_key" "target-features"="+v8.3a" {
|
|
entry:
|
|
tail call void %g() #2
|
|
ret i32 %a
|
|
}
|
|
|
|
|
|
; CHECK-LABEL: func:
|
|
; CHECK-NEXT: .seh_proc func
|
|
; CHECK-NEXT: // %bb.0:
|
|
; CHECK-NEXT: hint #27
|
|
; CHECK-NEXT: .seh_pac_sign_lr
|
|
; CHECK-NEXT: str x19, [sp, #-16]!
|
|
; CHECK-NEXT: .seh_save_reg_x x19, 16
|
|
; CHECK-NEXT: str x30, [sp, #8]
|
|
; CHECK-NEXT: .seh_save_reg x30, 8
|
|
; CHECK-NEXT: .seh_endprologue
|
|
|
|
; CHECK: .seh_startepilogue
|
|
; CHECK-NEXT: ldr x30, [sp, #8]
|
|
; CHECK-NEXT: .seh_save_reg x30, 8
|
|
; CHECK-NEXT: ldr x19, [sp], #16
|
|
; CHECK-NEXT: .seh_save_reg_x x19, 16
|
|
; CHECK-NEXT: hint #31
|
|
; CHECK-NEXT: .seh_pac_sign_lr
|
|
; CHECK-NEXT: .seh_endepilogue
|
|
; CHECK-NEXT: ret
|
|
; CHECK-NEXT: .seh_endfunclet
|
|
; CHECK-NEXT: .seh_endproc
|
|
|
|
;; For func2, check that the potentially folded autibsp+ret -> retab
|
|
;; is handled correctly - currently we inhibit producing retab here.
|
|
|
|
; CHECK-LABEL: func2:
|
|
; CHECK-NEXT: .seh_proc func2
|
|
; CHECK-NEXT: // %bb.0:
|
|
; CHECK-NEXT: pacibsp
|
|
; CHECK-NEXT: .seh_pac_sign_lr
|
|
; CHECK-NEXT: str x19, [sp, #-16]!
|
|
; CHECK-NEXT: .seh_save_reg_x x19, 16
|
|
; CHECK-NEXT: str x30, [sp, #8]
|
|
; CHECK-NEXT: .seh_save_reg x30, 8
|
|
; CHECK-NEXT: .seh_endprologue
|
|
|
|
; CHECK: .seh_startepilogue
|
|
; CHECK-NEXT: ldr x30, [sp, #8]
|
|
; CHECK-NEXT: .seh_save_reg x30, 8
|
|
; CHECK-NEXT: ldr x19, [sp], #16
|
|
; CHECK-NEXT: .seh_save_reg_x x19, 16
|
|
; CHECK-NEXT: autibsp
|
|
; CHECK-NEXT: .seh_pac_sign_lr
|
|
; CHECK-NEXT: .seh_endepilogue
|
|
; CHECK-NEXT: ret
|
|
; CHECK-NEXT: .seh_endfunclet
|
|
; CHECK-NEXT: .seh_endproc
|