public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC PATCH, i386]: Fix PR 63538, With -mcmodel=medium .lrodata accesses do not use 64-bit addresses
@ 2014-11-03 21:00 Uros Bizjak
  2014-11-04  9:46 ` Uros Bizjak
  0 siblings, 1 reply; 2+ messages in thread
From: Uros Bizjak @ 2014-11-03 21:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

Hello!

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  <ubizjak@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.

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1325 bytes --]

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 217050)
+++ config/i386/i386.c	(working copy)
@@ -5099,8 +5099,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 +5185,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 +44228,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;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH, i386]: Fix PR 63538, With -mcmodel=medium .lrodata accesses do not use 64-bit addresses
  2014-11-03 21:00 [RFC PATCH, i386]: Fix PR 63538, With -mcmodel=medium .lrodata accesses do not use 64-bit addresses Uros Bizjak
@ 2014-11-04  9:46 ` Uros Bizjak
  0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2014-11-04  9:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, Jakub Jelinek, Sriraman Tallam

[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]

On Mon, Nov 3, 2014 at 10:00 PM, Uros Bizjak <ubizjak@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  <ubizjak@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.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1798 bytes --]

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;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-04  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-03 21:00 [RFC PATCH, i386]: Fix PR 63538, With -mcmodel=medium .lrodata accesses do not use 64-bit addresses Uros Bizjak
2014-11-04  9:46 ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).