All of lore.kernel.org
 help / color / mirror / Atom feed
* Bad ARM code with GCC 4.7.1
@ 2012-05-10 14:28 Gary Thomas
  2012-05-10 15:46 ` Khem Raj
  0 siblings, 1 reply; 8+ messages in thread
From: Gary Thomas @ 2012-05-10 14:28 UTC (permalink / raw)
  To: Poky Project

After updating to the latest master, I'm running into trouble
using GCC 4.7.1 with my ARM kernel(s).

The problem code is in mm/percpu.c - this function [header]

static void pcpu_dump_alloc_info(const char *lvl,
				 const struct pcpu_alloc_info *ai)
{
	int group_width = 1, cpu_width = 1, width;
	char empty_str[] = "--------";
	int alloc = 0, alloc_end = 0;
	int group, v;
	int upa, apl;	/* units per alloc, allocs per line */

generates this code:

    0xc03669d0 <pcpu_dump_alloc_info>:   ldr     r3, [pc, #532]  ; 0xc0366bec <pcpu_dump_alloc_info+540>
    0xc03669d4 <pcpu_dump_alloc_info+4>: push    {r4, r5, r6, r7, r8, r9, r10, r11, lr}
    0xc03669d8 <pcpu_dump_alloc_info+8>: sub     sp, sp, #52     ; 0x34
    0xc03669dc <pcpu_dump_alloc_info+12>:        ldr     r2, [r3]
    0xc03669e0 <pcpu_dump_alloc_info+16>:        mov     r4, r1
    0xc03669e4 <pcpu_dump_alloc_info+20>:        mov     r10, r0

which in turn generates an alignment exception at pcpu_dump_alloc_info+12

The same code generates this using GCC 4.6.3

    0xc02bf6b0 <pcpu_dump_alloc_info>:   push    {r4, r5, r6, r7, r8, r9, r10, r11, lr}
    0xc02bf6b4 <pcpu_dump_alloc_info+4>: sub     sp, sp, #52     ; 0x34
    0xc02bf6b8 <pcpu_dump_alloc_info+8>: mov     r4, r1
    0xc02bf6bc <pcpu_dump_alloc_info+12>:        mov     r2, #9
    0xc02bf6c0 <pcpu_dump_alloc_info+16>:        str     r0, [sp, #20]
    0xc02bf6c4 <pcpu_dump_alloc_info+20>:        add     r0, sp, #39     ; 0x27
    0xc02bf6c8 <pcpu_dump_alloc_info+24>:        ldr     r1, [pc, #444]  ; 0xc02bf88c <pcpu_dump_alloc_info+476>
    0xc02bf6cc <pcpu_dump_alloc_info+28>:        mov     r9, #1
    0xc02bf6d0 <pcpu_dump_alloc_info+32>:        bl      0xc017f2a0 <memcpy>

Which looks much better to me - the runtime assignment
	char empty_str[] = "--------";
should cause the 9 byte string "--------" to be copied to the
stack variable.

I even tried to rewrite the code to match GCC 4.6.3 as
         char empty_str[10];
         memcpy(empty_str, "--------", 9);
but GCC 4.7.1 managed to generate the same bad code :-(

If I disable CONFIG_OPTIMIZE_FOR_SPEED, i.e. use -O2 instead of -Os,
this function is compiled properly.  Sadly, there are other gremlins
in there as Linux-3.0 still crashes when built with GCC 4.7.1

Are these known problems?  Are there work arounds?

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-05-10 20:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-10 14:28 Bad ARM code with GCC 4.7.1 Gary Thomas
2012-05-10 15:46 ` Khem Raj
2012-05-10 16:17   ` Gary Thomas
2012-05-10 16:30     ` Khem Raj
2012-05-10 16:49       ` Mark Hatle
2012-05-10 17:00         ` Khem Raj
2012-05-10 17:08       ` Gary Thomas
2012-05-10 20:06         ` Martin Jansa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.