Hi Currently the testcase in the patch was failing to produce a 'bti c' at the beginning of the function. This was because in aarch64_pac_insn_p, we were wrongly returning at the first check. This patch fixes the return value.
Bootstrap and regression tested on aarch64-none-linux-gnu. Is this ok for trunk and gcc 10 backport? Thanks Sudi gcc/ChangeLog: 2020-10-30 Sudakshina Das <sudi....@arm.com> PR target/97638 * config/aarch64/aarch64-bti-insert.c (aarch64_pac_insn_p): Update return value on INSN_P check. gcc/testsuite/ChangeLog: 2020-10-30 Sudakshina Das <sudi....@arm.com> PR target/97638 * gcc.target/aarch64/pr97638.c: New test. ############### Attachment also inlined for ease of reply ############### diff --git a/gcc/config/aarch64/aarch64-bti-insert.c b/gcc/config/aarch64/aarch64-bti-insert.c index 57663ee23b490162dbe7ffe2f618066e71cea455..98026695fdbbe2eda84e0befad94b5fe4ce22754 100644 --- a/gcc/config/aarch64/aarch64-bti-insert.c +++ b/gcc/config/aarch64/aarch64-bti-insert.c @@ -95,7 +95,7 @@ static bool aarch64_pac_insn_p (rtx x) { if (!INSN_P (x)) - return x; + return false; subrtx_var_iterator::array_type array; FOR_EACH_SUBRTX_VAR (iter, array, PATTERN (x), ALL) diff --git a/gcc/testsuite/gcc.target/aarch64/pr97638.c b/gcc/testsuite/gcc.target/aarch64/pr97638.c new file mode 100644 index 0000000000000000000000000000000000000000..e5869e86c449aef5606541c4c7a51069a1426793 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr97638.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mbranch-protection=bti" } */ + +char *foo (const char *s, const int c) +{ + const char *p = 0; + for (;;) + { + if (*s == c) + p = s; + if (p != 0 || *s++ == 0) + break; + } + return (char *)p; +} + +/* { dg-final { scan-assembler "hint\t34" } } */
rb13708.patch
Description: rb13708.patch