https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89355
Bug ID: 89355 Summary: Unnecessary ENDBR Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com CC: crazylht at gmail dot com, xuepeng.guo at intel dot com Target Milestone: --- Target: i386,x86-64 [hjl@gnu-cfl-2 gcc]$ cat x.i int test (int* val) { int status = 99; if((val == 0)) { status = 22; goto end; } extern int x; *val = x; status = 0; end: return status; } [hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S -O2 -fcf-protection x.i [hjl@gnu-cfl-2 gcc]$ cat x.s .file "x.i" .text .p2align 4 .globl test .type test, @function test: .LFB0: .cfi_startproc endbr64 testq %rdi, %rdi je .L3 movl x(%rip), %eax movl %eax, (%rdi) xorl %eax, %eax ret .p2align 4,,10 .p2align 3 .L3: .L2: endbr64 <<< Why is ENDBR here? There is no indirect branch. movl $22, %eax ret .cfi_endproc .LFE0: .size test, .-test .ident "GCC: (GNU) 9.0.1 20190214 (experimental)" .section .note.GNU-stack,"",@progbits .section .note.gnu.property,"a" .align 8 .long 1f - 0f .long 4f - 1f .long 5 0: .string "GNU" 1: .align 8 .long 0xc0000002 .long 3f - 2f 2: .long 0x3 3: .align 8 4: [hjl@gnu-cfl-2 gcc]$