[all-commits] [llvm/llvm-project] 178281: [Clang][ARM][AArch64] Alway emit protection attrib...

Daniel Kiss via All-commits all-commits at lists.llvm.org
Wed Jul 10 02:33:14 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1782810b8440144a0141c24192acbaeb55a1545d
      https://github.com/llvm/llvm-project/commit/1782810b8440144a0141c24192acbaeb55a1545d
  Author: Daniel Kiss <daniel.kiss at arm.com>
  Date:   2024-07-10 (Wed, 10 Jul 2024)

  Changed paths:
    M clang/include/clang/Basic/TargetInfo.h
    M clang/lib/CodeGen/Targets/AArch64.cpp
    M clang/lib/CodeGen/Targets/ARM.cpp
    M clang/test/CodeGen/aarch64-branch-protection-attr.c
    M clang/test/CodeGen/aarch64-sign-return-address.c
    M clang/test/CodeGen/aarch64-targetattr.c
    M clang/test/CodeGen/arm-branch-protection-attr-1.c
    M clang/test/CodeGen/arm-branch-protection-attr-2.c
    A clang/test/Frontend/arm-branch-protection-lto.c
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
    M llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
    M llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp
    M llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
    M llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
    M llvm/test/CodeGen/AArch64/kcfi-bti.ll
    M llvm/test/CodeGen/AArch64/machine-outliner-2fixup-blr-terminator.mir
    M llvm/test/CodeGen/AArch64/machine-outliner-bti.mir
    M llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
    M llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
    M llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
    M llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll
    M llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll
    M llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll
    M llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
    M llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
    M llvm/test/CodeGen/AArch64/setjmp-bti.ll
    M llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll
    M llvm/test/CodeGen/AArch64/sign-return-address.ll
    M llvm/test/CodeGen/AArch64/wineh-bti.ll
    M llvm/test/CodeGen/AArch64/wineh-pac.ll
    M llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
    M llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll
    M llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll
    M llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll
    M llvm/test/CodeGen/Thumb2/bti-outliner-1.ll
    M llvm/test/CodeGen/Thumb2/bti-outliner-2.ll
    M llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll
    M llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir
    M llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll
    M llvm/test/CodeGen/Thumb2/jump-table-bti.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-stack-arg.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll
    M llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll
    M llvm/test/LTO/AArch64/link-branch-target-enforcement.ll
    M llvm/test/Transforms/Inline/inline-sign-return-address.ll
    M llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll
    M llvm/test/Transforms/LowerTypeTests/function-thumb-bti.ll
    M llvm/test/Transforms/LowerTypeTests/function.ll
    M llvm/test/Verifier/branch-prot-attrs.ll

  Log Message:
  -----------
  [Clang][ARM][AArch64] Alway emit protection attributes for functions. (#82819)

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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list