This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: rs6000 -fdata-sections


Alan Modra <amodra@bigpond.net.au> writes:

> This simple testcase illustrates a problem with current powerpc-linux-gcc
> on both mainline and branch.
> 
> $ cat static.c
> const int a[10000] = {1, 2, };
> $ powerpc-linux-gcc -O2 -ffunction-sections -fdata-sections -S static.c
> $ cat static.s
>         .file   "static.c"
>         .globl  a
>         .section        .sdata.a,"a",@progbits
>         .align 2
>         .type   a,@object
>         .size   a,40000
> a:
>         .long   1
>         .long   2
>         .space  39992
>         .ident  "GCC: (GNU) 3.0.3 20011127 (prerelease)"
> 
> 'a' certainly shouldn't go into .sdata
> 
> The nub of the problem is that this expression
> 
>   sec = ((TREE_CODE (decl) == FUNCTION_DECL ? 0 : 1)
> 	 + (readonly ? 0 : 2) 
> 	 + (needs_sdata ? 1 : 0)
> 	 + (DECL_INITIAL (decl) == 0
> 	    || DECL_INITIAL (decl) == error_mark_node) ? 4 : 0);
> 
> is missing parentheses around the last term, but I didn't find that until
> I'd simplified things as in the following patch.  At least in my opinion
> it's simpler and gcc seems to agree, generating smaller and likely faster
> code.
> 
> 	* config/rs6000/rs6000.c (rs6000_unique_section): Simplify and
> 	correct code selecting section.
> 
> OK for mainline and branch?  Or should I just fix the missing parens on
> the branch?
> 
> Oh yeah, bootstrapping powerpc-linux at the moment.

I'd appreciate it if you could leave 'prefixes' as a two-dimensional
array, and leave the definitions of 'readonly' and 'needs_sdata', as
both of these provide important documentation; I'm really not a big
fan of the huge 'if ((x && a) || (y && b) || (z && (d || e)))'
conditions.  Rewriting the assignment to 'sec' as a sequence of
if-then conditions is good.  Can you submit a revised patch along
those lines?

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]