From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27735 invoked by alias); 26 Jun 2014 03:38:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27718 invoked by uid 89); 26 Jun 2014 03:38:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f172.google.com Received: from mail-ie0-f172.google.com (HELO mail-ie0-f172.google.com) (209.85.223.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 26 Jun 2014 03:38:44 +0000 Received: by mail-ie0-f172.google.com with SMTP id lx4so2524765iec.31 for ; Wed, 25 Jun 2014 20:38:42 -0700 (PDT) X-Received: by 10.42.120.80 with SMTP id e16mr11158935icr.55.1403753922273; Wed, 25 Jun 2014 20:38:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.117.101 with HTTP; Wed, 25 Jun 2014 20:38:22 -0700 (PDT) In-Reply-To: <53AB38AB.7040901@redhat.com> References: <53AB38AB.7040901@redhat.com> From: Kito Cheng Date: Thu, 26 Jun 2014 03:38:00 -0000 Message-ID: Subject: Re: [PATCH] Pass correct memory attributes for build constant To: Jeff Law Cc: gcc-patches@gcc.gnu.org, Jan Hubicka , Richard Sandiford , Eric Botcazou , Ramana Radhakrishnan Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg02087.txt.bz2 For example in arm-elf-eabi, movmem need word align, otherwise it will expand a libcall: And gcc configure with "--target=arm-elf-eabi --disable-nls --disable-shared --enable-languages=c,c++ --enable-threads=single --enable-lto --with-newlib" test.c: extern bar(unsigned char p[3][2]); void foo(int i) { unsigned char data[3][2] = {{1,1}, {1,0}, {1,1}}; bar(data); } Without this patch: ... .text .align 2 .global foo .type foo, %function foo: @ Function supports interworking. @ args = 0, pretend = 0, frame = 8 @ frame_needed = 0, uses_anonymous_args = 0 str lr, [sp, #-4]! sub sp, sp, #12 mov r2, #6 ldr r1, .L3 mov r0, sp bl memcpy @ LC0 has 4 byte align, but arm_gen_movmemqi can't get right alignment info mov r0, sp bl bar add sp, sp, #12 @ sp needed ldr lr, [sp], #4 bx lr .L4: .align 2 .L3: .word .LANCHOR0 .size foo, .-foo .section .rodata .align 2 .set .LANCHOR0,. + 0 .LC0: .byte 1 .byte 1 .byte 1 .byte 0 .byte 1 .byte 1 With this patch: ... foo: @ Function supports interworking. @ args = 0, pretend = 0, frame = 8 @ frame_needed = 0, uses_anonymous_args = 0 str lr, [sp, #-4]! ldr r3, .L3 @ LC0 has 4 byte align, arm_gen_movmemqi get right alignment info, so expand it! ldmia r3, {r0, r1} sub sp, sp, #12 str r0, [sp] mov r0, sp strh r1, [sp, #4] @ movhi bl bar add sp, sp, #12 @ sp needed ldr lr, [sp], #4 bx lr ... On Thu, Jun 26, 2014 at 5:01 AM, Jeff Law wrote: > On 06/25/14 09:35, Kito Cheng wrote: >> >> Hi all: >> This patch is fix constant memory's symbol_ref don't have right >> alignment info since `exp` don't set alignment (and should not set >> alignment info for `exp`) , use `decl` to set_mem_attributes for >> right alignment info. >> >> ChangLog >> 2014-06-25 Kito Cheng >> >> * varasm.c (build_constant_desc): Use decl to set mem >> attributes since exp don't have correct aligment info. > > Do you have a testcase for this? > > jeff >