On Mon, Nov 3, 2014 at 10:00 PM, Uros Bizjak <ubiz...@gmail.com> wrote:

> Following patch fixes PR 63538, where the data in the large data
> section was accessed through 32bit address. The patch unifies places
> where large data sections are determined and passes all declarations
> to ix86_in_large_data_p only.
>
> The patch fixes the testcase form the PR. Also, the code from several
> tests involving various -mlarge-data-threshold= settings looks
> consistent now.
>
> 2014-11-03  Uros Bizjak  <ubiz...@gmail.com>
>
>     PR target/63538
>     * config/i386/i386.c (ix86_encode_section_info): Do not check
>     TREE_STATIC and DECL_EXTERNAL when setting SYMBOL_FLAG_FAR_ADDR flag.
>     (x86_64_elf_select_section): Do not check ix86_cmodel here.
>     (x86_64_elf_unique_section): Ditto.
>
> The patch was bootstrapped and regression tested on x86_64-linux-gnu
> {,-m32}. However, the -mcmodel testcases are virtually non-existent,
> this is the reason for the RFC status of the patch.

I forgot to add the original reporter to CC ...

We probably want to avoid putting automatic variables (and STRING_CSTs
?) to large data section. However, it is important that we use the
same condition in ix86_encode_section_info and
x86_64_elf_select_section (and likes), otherwise the data can go into
large section, while the access to the data will be via limited 32bit
pointers.

The attached alternative patch rejects automatic variables and
STRING_CSTs from large data sections. Please note, that it still
access the data with the correct instructions.

Honza, can you please comment the approach from the ABI perspective -
should we reject automatic variables and STRING_CSTs from going into
large section?

Uros.
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 217069)
+++ config/i386/i386.c  (working copy)
@@ -5066,6 +5066,14 @@ ix86_in_large_data_p (tree exp)
   if (TREE_CODE (exp) == FUNCTION_DECL)
     return false;
 
+  /* Strings are never large data.  */
+  if (TREE_CODE (exp) == STRING_CST)
+    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);
@@ -5099,8 +5107,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;
@@ -5186,8 +5193,7 @@ x86_64_elf_section_type_flags (tree decl, const ch
 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.  */
@@ -44230,9 +44236,7 @@ ix86_encode_section_info (tree decl, rtx rtl, int
 {
   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;
 }
 

Reply via email to