[all-commits] [llvm/llvm-project] eb5ecb: [llvm][AArch64] Insert "bti j" after call to setjmp

David Spickett via All-commits all-commits at lists.llvm.org
Wed Mar 23 02:51:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eb5ecbbcbb6ce38e29237ab5d17156fcb2e96e74
      https://github.com/llvm/llvm-project/commit/eb5ecbbcbb6ce38e29237ab5d17156fcb2e96e74
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2022-03-23 (Wed, 23 Mar 2022)

  Changed paths:
    M clang/docs/ClangCommandLineReference.rst
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/Arch/AArch64.cpp
    M llvm/lib/Target/AArch64/AArch64.td
    M llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
    M llvm/lib/Target/AArch64/AArch64FastISel.cpp
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/lib/Target/AArch64/AArch64ISelLowering.h
    M llvm/lib/Target/AArch64/AArch64InstrInfo.td
    M llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
    A llvm/test/CodeGen/AArch64/setjmp-bti-no-enforcement.ll
    A llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
    A llvm/test/CodeGen/AArch64/setjmp-bti.ll

  Log Message:
  -----------
  [llvm][AArch64] Insert "bti j" after call to setjmp

Some implementations of setjmp will end with a br instead of a ret.
This means that the next instruction after a call to setjmp must be
a "bti j" (j for jump) to make this work when branch target identification
is enabled.

The BTI extension was added in armv8.5-a but the bti instruction is in the
hint space. This means we can emit it for any architecture version as long
as branch target enforcement flags are passed.

The starting point for the hint number is 32 then call adds 2, jump adds 4.
Hence "hint #36" for a "bti j" (and "hint #34" for the "bti c" you see
at the start of functions).

The existing Arm command line option -mno-bti-at-return-twice has been
applied to AArch64 as well.

Support is added to SelectionDAG Isel and GlobalIsel. FastIsel will
defer to SelectionDAG.

Based on the change done for M profile Arm in https://reviews.llvm.org/D112427

Fixes #48888

Reviewed By: danielkiss

Differential Revision: https://reviews.llvm.org/D121707




More information about the All-commits mailing list