From: Senthil Kumar Selvaraj Date: Thu, 16 Jun 2016 16:50:40 +0000 (+0000) Subject: avr.c (avr_asm_init_sections): Remove setup of progmem_swtable_section. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2d761a3733c10868e8ca8d81e846a1940c5e48a2;p=gcc.git avr.c (avr_asm_init_sections): Remove setup of progmem_swtable_section. gcc/ChangeLog: * config/avr/avr.c (avr_asm_init_sections): Remove setup of progmem_swtable_section. (progmem_swtable_section): Remove. (avr_asm_function_rodata_section): Remove. (TARGET_ASM_FUNCTION_RODATA_SECTION): Remove. * config/avr/avr.h (JUMP_TABLES_IN_TEXT_SECTION: Define to 1. gcc/testsuite/ChangeLog: * gcc.target/avr/pr71151-1.c: New test. * gcc.target/avr/pr71151-2.c: New test. * gcc.target/avr/pr71151-3.c: New test. * gcc.target/avr/pr71151-4.c: New test. * gcc.target/avr/pr71151-5.c: New test. * gcc.target/avr/pr71151-6.c: New test. * gcc.target/avr/pr71151-7.c: New test. * gcc.target/avr/pr71151-8.c: New test. * gcc.target/avr/pr71151-common.h: New test. From-SVN: r237536 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5215b801a6b..eb0ca9117cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2016-06-16 Senthil Kumar Selvaraj + + * config/avr/avr.c (avr_asm_init_sections): Remove setup of + progmem_swtable_section. + (progmem_swtable_section): Remove. + (avr_asm_function_rodata_section): Remove. + (TARGET_ASM_FUNCTION_RODATA_SECTION): Remove. + * config/avr/avr.h (JUMP_TABLES_IN_TEXT_SECTION: Define to 1. + 2016-06-16 Jocelyn Mayer * config/i386/driver-i386.c (host_detect_local_cpu): Set diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index b3276243902..d13f4fddcd5 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -203,9 +203,6 @@ static GTY(()) rtx xstring_e; /* Current architecture. */ const avr_arch_t *avr_arch; -/* Section to put switch tables in. */ -static GTY(()) section *progmem_swtable_section; - /* Unnamed sections associated to __attribute__((progmem)) aka. PROGMEM or to address space __flash* or __memx. Only used as singletons inside avr_asm_select_section, but it must not be local there because of GTY. */ @@ -9461,24 +9458,6 @@ avr_output_progmem_section_asm_op (const void *data) static void avr_asm_init_sections (void) { - /* Set up a section for jump tables. Alignment is handled by - ASM_OUTPUT_BEFORE_CASE_LABEL. */ - - if (AVR_HAVE_JMP_CALL) - { - progmem_swtable_section - = get_unnamed_section (0, output_section_asm_op, - "\t.section\t.progmem.gcc_sw_table" - ",\"a\",@progbits"); - } - else - { - progmem_swtable_section - = get_unnamed_section (SECTION_CODE, output_section_asm_op, - "\t.section\t.progmem.gcc_sw_table" - ",\"ax\",@progbits"); - } - /* Override section callbacks to keep track of `avr_need_clear_bss_p' resp. `avr_need_copy_data_p'. */ @@ -9488,65 +9467,6 @@ avr_asm_init_sections (void) } -/* Implement `TARGET_ASM_FUNCTION_RODATA_SECTION'. */ - -static section* -avr_asm_function_rodata_section (tree decl) -{ - /* If a function is unused and optimized out by -ffunction-sections - and --gc-sections, ensure that the same will happen for its jump - tables by putting them into individual sections. */ - - unsigned int flags; - section * frodata; - - /* Get the frodata section from the default function in varasm.c - but treat function-associated data-like jump tables as code - rather than as user defined data. AVR has no constant pools. */ - { - int fdata = flag_data_sections; - - flag_data_sections = flag_function_sections; - frodata = default_function_rodata_section (decl); - flag_data_sections = fdata; - flags = frodata->common.flags; - } - - if (frodata != readonly_data_section - && flags & SECTION_NAMED) - { - /* Adjust section flags and replace section name prefix. */ - - unsigned int i; - - static const char* const prefix[] = - { - ".rodata", ".progmem.gcc_sw_table", - ".gnu.linkonce.r.", ".gnu.linkonce.t." - }; - - for (i = 0; i < sizeof (prefix) / sizeof (*prefix); i += 2) - { - const char * old_prefix = prefix[i]; - const char * new_prefix = prefix[i+1]; - const char * name = frodata->named.name; - - if (STR_PREFIX_P (name, old_prefix)) - { - const char *rname = ACONCAT ((new_prefix, - name + strlen (old_prefix), NULL)); - flags &= ~SECTION_CODE; - flags |= AVR_HAVE_JMP_CALL ? 0 : SECTION_CODE; - - return get_section (rname, flags, frodata->named.decl); - } - } - } - - return progmem_swtable_section; -} - - /* Implement `TARGET_ASM_NAMED_SECTION'. */ /* Track need of __do_clear_bss, __do_copy_data for named sections. */ @@ -13747,9 +13667,6 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, #undef TARGET_FOLD_BUILTIN #define TARGET_FOLD_BUILTIN avr_fold_builtin -#undef TARGET_ASM_FUNCTION_RODATA_SECTION -#define TARGET_ASM_FUNCTION_RODATA_SECTION avr_asm_function_rodata_section - #undef TARGET_SCALAR_MODE_SUPPORTED_P #define TARGET_SCALAR_MODE_SUPPORTED_P avr_scalar_mode_supported_p diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index 01da70867e4..ab5e4651148 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -391,7 +391,7 @@ typedef struct avr_args #define SUPPORTS_INIT_PRIORITY 0 -#define JUMP_TABLES_IN_TEXT_SECTION 0 +#define JUMP_TABLES_IN_TEXT_SECTION 1 #define ASM_COMMENT_START " ; " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3dfb452358d..b62a0f9468e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2016-06-16 Senthil Kumar Selvaraj + + * gcc.target/avr/pr71151-1.c: New test. + * gcc.target/avr/pr71151-2.c: New test. + * gcc.target/avr/pr71151-3.c: New test. + * gcc.target/avr/pr71151-4.c: New test. + * gcc.target/avr/pr71151-5.c: New test. + * gcc.target/avr/pr71151-6.c: New test. + * gcc.target/avr/pr71151-7.c: New test. + * gcc.target/avr/pr71151-8.c: New test. + * gcc.target/avr/pr71151-common.h: New test. + 2016-06-16 Martin Liska * gfortran.dg/predict-1.f90: New test. diff --git a/gcc/testsuite/gcc.target/avr/pr71151-1.c b/gcc/testsuite/gcc.target/avr/pr71151-1.c new file mode 100644 index 00000000000..615dce86026 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -ffunction-sections -fdata-sections" } */ + +/* { dg-final { scan-assembler-not ".section .progmem.gcc_sw_table.foo.str1.1" } } */ +/* { dg-final { scan-assembler ".section .rodata.foo.str1.1,\"aMS\"" } } */ + + +extern void bar(const char*); +void foo(void) +{ + bar("BBBBBBBBBB"); +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-2.c b/gcc/testsuite/gcc.target/avr/pr71151-2.c new file mode 100644 index 00000000000..e523ce09c7a --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections" } */ + +/* Make sure jumptables work properly if placed below 64 KB i.e. 2 byte + flash address for loading jump table entry, 2 byte entry, after + removing the special section placement hook. */ + +#include "exit-abort.h" +#include "pr71151-common.h" + +int main() +{ + foo(5); + if (y != 37) + abort(); + + foo(0); + if (y != 67) + abort(); + + foo(7); + if (y != 98) + abort(); +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-3.c b/gcc/testsuite/gcc.target/avr/pr71151-3.c new file mode 100644 index 00000000000..ce0ba5972e4 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-3.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -mno-relax -fdata-sections -Wl,--section-start=.foo=0x10000" } */ + +/* Make sure jumptables work properly if placed above 64 KB and below 128 KB, + i.e. 3 byte flash address for loading jump table entry and 2 byte jump table + entry, with relaxation disabled, after removing the special section + placement hook. */ + +#include "exit-abort.h" +#include "pr71151-common.h" + +int main() +{ + foo(5); + if (y != 37) + abort(); + + foo(0); + if (y != 67) + abort(); + + foo(7); + if (y != 98) + abort(); +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-4.c b/gcc/testsuite/gcc.target/avr/pr71151-4.c new file mode 100644 index 00000000000..51250b06133 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-4.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x10000" } */ + +/* Make sure jumptables work properly if placed above 64 KB and below 128 KB, + i.e. 3 byte flash address for loading jump table entry and 2 byte jump + table entry, with relaxation enabled, after removing the special section + placement hook. */ + +#include "exit-abort.h" +#include "pr71151-common.h" + +int main() +{ + foo(5); + if (y != 37) + abort(); + + foo(0); + if (y != 67) + abort(); + + foo(7); + if (y != 98) + abort(); +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-5.c b/gcc/testsuite/gcc.target/avr/pr71151-5.c new file mode 100644 index 00000000000..47030dca5ee --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-5.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x20000" } */ + +/* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte + flash address for loading jump table entry and a jump table entry + that is a stub, with relaxation disabled, after removing the special + section placement hook. */ + +#include "exit-abort.h" +#include "pr71151-common.h" + +int main() +{ + /* Not meant for devices with flash <= 128K */ +#if defined (__AVR_2_BYTE_PC__) + exit(0); +#else + foo(5); + if (y != 37) + abort(); + + foo(0); + if (y != 67) + abort(); + + foo(7); + if (y != 98) + abort(); +#endif +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-6.c b/gcc/testsuite/gcc.target/avr/pr71151-6.c new file mode 100644 index 00000000000..815aa13425c --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-6.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x20000" } */ + +/* Make sure jumptables work properly if placed above 128 KB, i.e. 3 byte + flash address for loading jump table entry and a jump table entry + that is a stub, with relaxation enabled, after removing the special + section placement hook. */ + +#include "exit-abort.h" +#include "pr71151-common.h" + +int main() +{ + /* Not meant for devices with flash <= 128K */ +#if defined (__AVR_2_BYTE_PC__) + exit(0); +#else + foo(5); + if (y != 37) + abort(); + + foo(0); + if (y != 67) + abort(); + + foo(7); + if (y != 98) + abort(); +#endif +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-7.c b/gcc/testsuite/gcc.target/avr/pr71151-7.c new file mode 100644 index 00000000000..cdc7ea9f65c --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-7.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mno-relax -Wl,--section-start=.foo=0x1fffa" } */ + +/* Make sure jumptables work properly if placed straddling 128 KB i.e + some entries below 128 KB and some above it, with relaxation disabled. */ + +#include "exit-abort.h" +#include "pr71151-common.h" + +int main() +{ + /* Not meant for devices with flash <= 128K */ +#if defined (__AVR_2_BYTE_PC__) + exit(0); +#else + foo(5); + if (y != 37) + abort(); + + foo(0); + if (y != 67) + abort(); + + foo(7); + if (y != 98) + abort(); +#endif +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-8.c b/gcc/testsuite/gcc.target/avr/pr71151-8.c new file mode 100644 index 00000000000..0b7bf6a0e73 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-8.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-Os -fno-tree-switch-conversion -ffunction-sections -fdata-sections -mrelax -Wl,--section-start=.foo=0x1fffa" } */ + +/* Make sure jumptables work properly if placed straddling 128 KB i.e + some entries below 128 KB and some above it, with relaxation disabled. */ + +#include "exit-abort.h" +#include "pr71151-common.h" + +int main() +{ + /* Not meant for devices with flash <= 128K */ +#if defined (__AVR_2_BYTE_PC__) + exit(0); +#else + foo(5); + if (y != 37) + abort(); + + foo(0); + if (y != 67) + abort(); + + foo(7); + if (y != 98) + abort(); +#endif +} diff --git a/gcc/testsuite/gcc.target/avr/pr71151-common.h b/gcc/testsuite/gcc.target/avr/pr71151-common.h new file mode 100644 index 00000000000..0df17836b99 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71151-common.h @@ -0,0 +1,27 @@ +volatile char y; +volatile char g; + +__attribute__((section(".foo"))) +void foo(char x) +{ + switch (x) + { + case 0: + y = 67; break; + case 1: + y = 20; break; + case 2: + y = 109; break; + case 3: + y = 33; break; + case 4: + y = 44; break; + case 5: + y = 37; break; + case 6: + y = 10; break; + case 7: + y = 98; break; + } + y = y + g; +}