From: Richard Ball <richard.b...@arm.com> This patch adds a new testcase and docs for the indirect_return attribute.
gcc/ChangeLog: * doc/extend.texi: Add AArch64 docs for indirect_return attribute. gcc/testsuite/ChangeLog: * gcc.target/aarch64/indirect_return.c: New test. Co-authored-by: Yury Khrustalev <yury.khrusta...@arm.com> --- gcc/doc/extend.texi | 5 ++++ .../gcc.target/aarch64/indirect_return.c | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/indirect_return.c diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 42bd567119d..45e2b3ec569 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -4760,6 +4760,11 @@ Enable or disable calls to out-of-line helpers to implement atomic operations. This corresponds to the behavior of the command-line options @option{-moutline-atomics} and @option{-mno-outline-atomics}. +@cindex @code{indirect_return} function attribute, AArch64 +@item indirect_return +Used to inform the compiler that a function may return via +an indirect return. Adds a BTI J instruction under @option{mbranch-protection=} bti. + @end table The above target attributes can be specified as follows: diff --git a/gcc/testsuite/gcc.target/aarch64/indirect_return.c b/gcc/testsuite/gcc.target/aarch64/indirect_return.c new file mode 100644 index 00000000000..f1ef56d5557 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/indirect_return.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-mbranch-protection=bti" } */ + +int __attribute((indirect_return)) +foo (int a) +{ + return a; +} + +/* +**func1: +** hint 34 // bti c +** ... +** bl foo +** hint 36 // bti j +** ... +** ret +*/ +int +func1 (int a, int b) +{ + return foo (a + b); +} + +/* { dg-final { check-function-bodies "**" "" "" } } */ -- 2.39.5