[ARM] Implement setjmp BTI placement for PACBTI-M
authorTies Stuij <ties.stuij@arm.com>
Mon, 6 Dec 2021 11:00:10 +0000 (11:00 +0000)
committerTies Stuij <ties.stuij@arm.com>
Mon, 6 Dec 2021 11:07:10 +0000 (11:07 +0000)
commit0fbb17458a01a6b388fc67661ffb92969503e977
treed5a8c0f92120b52be024f8ec8c7cb52a624f4a10
parent6b41eb7f26d06ce018c0218360f9cdec239f2caa
[ARM] Implement setjmp BTI placement for PACBTI-M

This patch intends to guard indirect branches performed by longjmp
by inserting BTI instructions after calls to setjmp.

Calls with 'returns-twice' are lowered to a new pseudo-instruction
named t2CALL_BTI that is later expanded to a bundle of {tBL,t2BTI}.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Alexandros Lamprineas
- Ties Stuij

Reviewed By: labrinea

Differential Revision: https://reviews.llvm.org/D112427
12 files changed:
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/arm-bti-return-twice.c [new file with mode: 0644]
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMISelLowering.h
llvm/lib/Target/ARM/ARMInstrThumb2.td
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/test/CodeGen/ARM/setjmp-bti-basic.ll [new file with mode: 0644]
llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll [new file with mode: 0644]