https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92841
Bug ID: 92841 Summary: Optimize -fstack-protector-strong code generation a bit Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: bp at alien8 dot de Target Milestone: --- Created attachment 47435 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47435&action=edit prepocessed source Hi, I'm building the linux kernel with gcc (Debian 9.2.1-8) 9.2.1 20190909 and -fstack-protector-strong on x86 and from looking at what it generates, it could be optimized a little: # arch/x86/kernel/cpu/scattered.c:48: { movq %gs:40, %rax # MEM[(<address-space-2> long unsigned int *)40B], tmp125 movq %rax, 16(%rsp) # tmp125, D.21425 xorl %eax, %eax # tmp125 movl $6, %eax #, pretmp_35 jmp .L6 # AFAICT, the stack protector part would load the canary value from the %gs offset and use a temp register to stick it on the stack and then clear that temp register, %rax in this case. As part of further function processing, it would stick a value in that same register, which makes the previous clearing superfluous. I'm being told this could be taken care of in a "late peephole". :) Attaching preprocessed source. Thx.