From owner-freebsd-arm@FreeBSD.ORG Fri Dec 28 16:47:52 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7BBC11000; Fri, 28 Dec 2012 16:47:52 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-we0-f169.google.com (mail-we0-f169.google.com [74.125.82.169]) by mx1.freebsd.org (Postfix) with ESMTP id CC1088FC08; Fri, 28 Dec 2012 16:47:51 +0000 (UTC) Received: by mail-we0-f169.google.com with SMTP id t49so5113575wey.0 for ; Fri, 28 Dec 2012 08:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=YAzhJDFjsSEWLWiT0/4oZO+/AFDTKZwD7FsCEQQ29eU=; b=asBiUtFZQuHIuI/qjAi7eCEgjWgOCZK9BxIJ1XVPulUUZI6p/M26N1cQdru7NXZ2FQ 1b5C6xDOsA12cifVQZ/l/CkC4TGmfxlEB+DHIMGa1CEnT1d7Ss8kVkCFihq/VEXa1fS8 BRLU4thVX+HqBsIplUEdz9Ci1EtGL2scge/Y3xSGbDjR0uhYrWHydi/WdG5dQrYanEbG AvwqsTP087K/kUA5zM7yZak5jzPNktlSDgGr9lgoz2xRrS+UH96oHYtKlSt1yHdDyrTZ My5XXwDFpV6ICQtmEddvPw3Y6uCNoodWn8FCk9H90xJGqUCzNsswKp77azrWajJVbwMq aU9Q== MIME-Version: 1.0 Received: by 10.180.8.130 with SMTP id r2mr46389623wia.28.1356713264727; Fri, 28 Dec 2012 08:47:44 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.217.57.9 with HTTP; Fri, 28 Dec 2012 08:47:44 -0800 (PST) In-Reply-To: <9ED42265200A41B1BD637682720E0E9D@ad.peach.ne.jp> References: <2BA73CBF02B04DD19D08CDFC556B8750@ad.peach.ne.jp> <1356624694.1144.67.camel@revolution.hippie.lan> <234E1E18AC1C4A3985D6C570F78698E6@ad.peach.ne.jp> <9ED42265200A41B1BD637682720E0E9D@ad.peach.ne.jp> Date: Fri, 28 Dec 2012 08:47:44 -0800 X-Google-Sender-Auth: FLDfvQk_u6ajYAK9qKAWe8iesDI Message-ID: Subject: Re: FreeBSD/armv6z/clang on Raspberry Pi 512MB (with U-Boot + ubldr) From: Adrian Chadd To: Daisuke Aoyama , David Chisnall Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-arm@freebsd.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Dec 2012 16:47:52 -0000 .. the compiler should know the alignment for each of those types and pad the structure appropriately, right? david - what's the "right" behaviour here? Surely clang should be inserting 4 bytes of padding before that pointer? Adrian On 28 December 2012 08:41, Daisuke Aoyama wrote: >>>> This is complete version of systimer patch. >>>> It should fix stopping interrupt and related things such as USB LAN is >>>> unstable, >>>> SSH is closed suddenly. >>>> (I've not yet finished all test at this time, but at least portsnap >>>> fetch is >>>> success. >>>> Now extracting the ports without any problems.) > > > Finished without any problems. > > > I'm checking the alignment of clang now. It seems no difference of location > of data structure. > However, access method is different. > > I learned clang will combine two loads into one op. > This is a reason why the alignment seems difference between clang and gcc. > Also, a reason why clang binary is smaller than gcc code. > > According to ARM manual, strd alignment is: > "The address must be a multiple of eight for doubleword transfers." > > uboot/lib/api_public.h: > ---------------------------------------------------------------------- > struct sys_info { > unsigned long clk_bus; > unsigned long clk_cpu; > unsigned long bar; > struct mem_region *mr; /* << mr offset is 12!! (not DW > aligned) */ > int mr_no; /* number of memory regions */ > }; > > uboot/lib/glue.c: > ---------------------------------------------------------------------- > struct sys_info * > ub_get_sys_info(void) > { > int err = 0; > > memset(&si, 0, sizeof(struct sys_info)); > si.mr = mr; > si.mr_no = UB_MAX_MR; > memset(&mr, 0, sizeof(mr)); > > if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si)) > return (NULL); > > return ((err) ? NULL : &si); > } > > ---------------------------------------------------------------------- > clang -O2 output (7 steps): > bl memset ; ATPCS uses r0-r3 as parameters > ldr r0, .LCPI6_1 ; mr > mov r1, #5 ; UB_MAX_MR > mov r2, #60 ; sizeof(mr) > strd r0, r1, [r5, #12] ; r5 aligned but strd requires DW(8byte) > alignment (faulted here) > mov r1, #0 > bl memset ; memset(&mr, 0, sizeof(mr)); > > clang final binary size(2.8% smaller): > -rwxr-xr-x 1 root wheel 235984 Dec 28 23:49 ubldr > ---------------------------------------------------------------------- > gcc 4.2 -O2 output (9 steps): > bl memset ; ATPCS uses r0-r3 as parameters > ldr ip, .L162+4 ; mr > mov r3, #5 ; UB_MAX_MR > mov r1, r4 ; r4 is zero > mov r0, ip ; << what?? > mov r2, #60 ; sizeof(mr) > str r3, [r6, #16] ; r6 aligned same as clang > str ip, [r6, #12] ; r6 aligned same as clang > bl memset ; memset(&mr, 0, sizeof(mr)); > > gcc final binary size: > -rwxr-xr-x 1 root wheel 242810 Dec 28 18:22 ubldr > ---------------------------------------------------------------------- > I don't know gcc 4.3 or newer, but probably output is more smart. > It seems that there is no reason to use ip in this case. > > Does any one know how to prevent above clang output? > (or how to solve this issue for all codes.) > > Thanks > > -- > Daisuke Aoyama > > > _______________________________________________ > freebsd-arm@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"