From b478c0cd398851b78a85b0667f3997b424e42f35 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Wed, 5 Nov 2014 22:00:07 +0100 Subject: [PATCH] re PR target/63538 ([X86_64] With -mcmodel=medium .lrodata accesses do not use 64-bit addresses) PR target/63538 * config/i386/i386.c (in_large_data_p): Reject automatic variables. (ix86_encode_section_info): Do not check for non-automatic varibles when setting SYMBOL_FLAG_FAR_ADDR flag. (x86_64_elf_select_section): Do not check ix86_cmodel here. (x86_64_elf_unique_section): Ditto. (x86_elf_aligned_common): Emit tab before .largecomm. testsuite/ChangeLog: PR target/63538 * gcc.target/i386/pr63538.c: New test. From-SVN: r217156 --- gcc/ChangeLog | 10 ++++++++++ gcc/config/i386/i386.c | 16 ++++++++-------- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/gcc.target/i386/pr63538.c | 13 +++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr63538.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 778ce1fd64f..ead29c3897e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-11-05 Uros Bizjak + + PR target/63538 + * config/i386/i386.c (in_large_data_p): Reject automatic variables. + (ix86_encode_section_info): Do not check for non-automatic varibles + when setting SYMBOL_FLAG_FAR_ADDR flag. + (x86_64_elf_select_section): Do not check ix86_cmodel here. + (x86_64_elf_unique_section): Ditto. + (x86_elf_aligned_common): Emit tab before .largecomm. + 2014-11-05 Anthony Brandon PR driver/36312 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 0a4c13bed44..085eb547621 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5090,6 +5090,10 @@ ix86_in_large_data_p (tree exp) if (TREE_CODE (exp) == FUNCTION_DECL) return false; + /* Automatic variables are never large data. */ + if (TREE_CODE (exp) == VAR_DECL && !is_global_var (exp)) + return false; + if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp)) { const char *section = DECL_SECTION_NAME (exp); @@ -5123,8 +5127,7 @@ ATTRIBUTE_UNUSED static section * x86_64_elf_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align) { - if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) - && ix86_in_large_data_p (decl)) + if (ix86_in_large_data_p (decl)) { const char *sname = NULL; unsigned int flags = SECTION_WRITE; @@ -5210,8 +5213,7 @@ x86_64_elf_section_type_flags (tree decl, const char *name, int reloc) static void ATTRIBUTE_UNUSED x86_64_elf_unique_section (tree decl, int reloc) { - if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) - && ix86_in_large_data_p (decl)) + if (ix86_in_large_data_p (decl)) { const char *prefix = NULL; /* We only need to use .gnu.linkonce if we don't have COMDAT groups. */ @@ -5280,7 +5282,7 @@ x86_elf_aligned_common (FILE *file, { if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) && size > (unsigned int)ix86_section_threshold) - fputs (".largecomm\t", file); + fputs ("\t.largecomm\t", file); else fputs (COMMON_ASM_OP, file); assemble_name (file, name); @@ -45178,9 +45180,7 @@ ix86_encode_section_info (tree decl, rtx rtl, int first) { default_encode_section_info (decl, rtl, first); - if (TREE_CODE (decl) == VAR_DECL - && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)) - && ix86_in_large_data_p (decl)) + if (ix86_in_large_data_p (decl)) SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= SYMBOL_FLAG_FAR_ADDR; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c699ce31b4f..4e64c97a4b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-11-05 Uros Bizjak + + PR target/63538 + * gcc.target/i386/pr63538.c: New test. + 2014-11-05 Eric Botcazou * gnat.dg/discr42.adb: New test. @@ -21,7 +26,7 @@ * gnat.dg/inline5.adb: New test. * gnat.dg/inline5_pkg.ad[sb]: New helper. * gnat.dg/inline6.adb: New test. - * gnat.dg/inline6_pkg.ad[sb]: New helper. + * gnat.dg/inline6_pkg.ad[sb]: New helper. * gnat.dg/inline7.adb: New test. * gnat.dg/inline7_pkg1.ad[sb]: New helper. * gnat.dg/inline7_pkg2.ad[sb]: Likewise. diff --git a/gcc/testsuite/gcc.target/i386/pr63538.c b/gcc/testsuite/gcc.target/i386/pr63538.c new file mode 100644 index 00000000000..7b979c35d81 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr63538.c @@ -0,0 +1,13 @@ +/* PR target/63538 */ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -mcmodel=medium -mlarge-data-threshold=0" } */ + +static char *str = "Hello World"; + +char *foo () +{ + return str; +} + +/* { dg-final { scan-assembler "movabs" } } */ -- 2.30.2