From 335b7b5ad22ced0e2d4af7a3002a727caafbad02 Mon Sep 17 00:00:00 2001 From: Segher Boessenkool Date: Wed, 7 Mar 2018 21:27:11 +0100 Subject: [PATCH] rs6000: -mreadonly-in-sdata (PR82411) This adds a new option -mreadonly-in-sdata (on by default) that controls whether readonly data can be put in sdata. (For EABI this does nothing, readonly data is put in sdata2 as usual). PR target/82411 * config/rs6000/rs6000.c (rs6000_elf_in_small_data_p): Don't put readonly data in sdata, if that is disabled. * config/rs6000/sysv4.opt (mreadonly-in-sdata): New option. * doc/invoke.texi (RS/6000 and PowerPC Options): Document -mreadonly-in-sdata option. gcc/testsuite/ PR target/82411 * gcc.target/powerpc/ppc-sdata-2.c: Skip if -mno-readonly-in-sdata. From-SVN: r258340 --- gcc/ChangeLog | 9 +++++++++ gcc/config/rs6000/rs6000.c | 5 +++++ gcc/config/rs6000/sysv4.opt | 4 ++++ gcc/doc/invoke.texi | 9 ++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c | 1 + 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e988ed7199..666985ef002 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-03-07 Segher Boessenkool + + PR target/82411 + * config/rs6000/rs6000.c (rs6000_elf_in_small_data_p): Don't put + readonly data in sdata, if that is disabled. + * config/rs6000/sysv4.opt (mreadonly-in-sdata): New option. + * doc/invoke.texi (RS/6000 and PowerPC Options): Document + -mreadonly-in-sdata option. + 2018-03-07 Martin Sebor PR tree-optimization/84468 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 9c8c0c83934..63f62d47e8b 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -33259,6 +33259,11 @@ rs6000_elf_in_small_data_p (const_tree decl) } else { + /* If we are told not to put readonly data in sdata, then don't. */ + if (TREE_READONLY (decl) && rs6000_sdata != SDATA_EABI + && !rs6000_readonly_in_sdata) + return false; + HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl)); if (size > 0 diff --git a/gcc/config/rs6000/sysv4.opt b/gcc/config/rs6000/sysv4.opt index 9534c1ce282..fb03c0ac80a 100644 --- a/gcc/config/rs6000/sysv4.opt +++ b/gcc/config/rs6000/sysv4.opt @@ -27,6 +27,10 @@ msdata= Target RejectNegative Joined Var(rs6000_sdata_name) Select method for sdata handling. +mreadonly-in-sdata +Target Report Var(rs6000_readonly_in_sdata) Init(1) Save +Allow readonly data in sdata. + mtls-size= Target RejectNegative Joined Var(rs6000_tls_size) Enum(rs6000_tls_size) Specify bit size of immediate TLS offsets. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 80e4efffe11..2492148b30f 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1087,7 +1087,7 @@ See RS/6000 and PowerPC Options. -mdlmzb -mno-dlmzb @gol -mprototype -mno-prototype @gol -msim -mmvme -mads -myellowknife -memb -msdata @gol --msdata=@var{opt} -mvxworks -G @var{num} @gol +-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol -mno-recip-precision @gol -mveclibabi=@var{type} -mfriz -mno-friz @gol @@ -24114,6 +24114,13 @@ On embedded PowerPC systems, put all initialized global and static data in the @code{.data} section, and all uninitialized data in the @code{.bss} section. +@item -mreadonly-in-sdata +@itemx -mreadonly-in-sdata +@opindex mreadonly-in-sdata +@opindex mno-readonly-in-sdata +Put read-only objects in the @code{.sdata} section as well. This is the +default. + @item -mblock-move-inline-limit=@var{num} @opindex mblock-move-inline-limit Inline all block moves (such as calls to @code{memcpy} or structure diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e273c6bf6c..080164d421a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-07 Segher Boessenkool + + PR target/82411 + * gcc.target/powerpc/ppc-sdata-2.c: Skip if -mno-readonly-in-sdata. + 2018-03-07 Martin Sebor PR tree-optimization/84468 diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c b/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c index 570c81f7e33..ee77456ca4f 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c @@ -5,6 +5,7 @@ /* { dg-final { scan-assembler-not "\\.section\[ \t\]\\.sdata2," } } */ /* { dg-final { scan-assembler "sdat@sdarel\\(13\\)" } } */ /* { dg-final { scan-assembler "sdat2@sdarel\\(13\\)" } } */ +/* { dg-skip-if "" { *-*-* } { "-mno-readonly-in-sdata" } { "" } } */ int sdat = 2; -- 2.30.2