https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97638
Bug ID: 97638
Summary: aarch64: bti c is missing at function entry with
branch-protection
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: nsz at gcc dot gnu.org
Target Milestone: ---
gcc-10 (and trunk) with -mbranch-protection=bti (or standard)
fails to generate bti c at function entry in some cases:
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;
}
gcc -O2 -mbranch-protection=bti is
foo:
.L3:
ldrb w2, [x0]
cmp w2, w1
beq .L2
add x0, x0, 1
cbnz w2, .L3
mov x0, 0
.L2:
ret