Date: Tue, 4 Jun 2002 11:04:27 -0700 (PDT) From: "David E. O'Brien" <obrien@FreeBSD.org> To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/contrib/gcc builtins.c Message-ID: <200206041804.g54I4SW66115@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
obrien 2002/06/04 11:04:27 PDT Modified files: contrib/gcc builtins.c Log: Gcc 3.1 (-O) now generates broken inline code for memset in some cases. This broke newfs (newfs left some garbage in a bitmap). The ASM for: #include <string.h> int x, foo[100]; main() { memset(&foo[0], 0, x); } is (at least if you have fixed function alignment): .file "z.c" .text .p2align 2,,3 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp pushl %edi pushl %eax movl x, %ecx xorl %eax, %eax shrl $2, %ecx movl $foo, %edi cld rep stosl andl $-16, %esp <-- the lower bits of `len' should be loaded near here testl $2, %edi <-- this seems to be meant to test the 2^1 bit in `len' (not alignment of the pointer like it actually does). %edi is the wrong register for holding the bits, since it is still needed for the pointer. je .L2 stosw .L2: testl $1, %edi <-- similarly for the 2^0 bit. je .L3 stosb .L3: movl -4(%ebp), %edi leave ret .Lfe1: .size main,.Lfe1-main .comm foo,400,32 .comm x,4,4 .ident "GCC: (GNU) 3.1 [FreeBSD] 20020509 (prerelease)" This seems to only result in (len % 3) bytes not being cleared, since gcc doesn't seem to use the builtin memset unless it knows that the pointer is aligned. If %edi could be misaligned, then too many bytes would be set. Submitted by: BDE Revision Changes Path 1.2 +69 -28 src/contrib/gcc/builtins.c To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206041804.g54I4SW66115>