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 <[email protected]> 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 <[email protected]>
>>
>> * 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
>