diff mbox

[committed] Change "Q" and "T" constraints to memory constraints

Message ID BLU436-SMTP164FFBA31AD0A827A87B35997230@phx.gbl
State New
Headers show

Commit Message

John David Anglin Feb. 13, 2015, 1:22 p.m. UTC
The recent change to use the "Q" constraint instead of the "m" constraint in several patterns caused
a regression that broke the build of the Debian webkitgtk package.  Memory addresses (spills) with out
of range offsets were not being reloaded in functions with large frames.  This change fixes that problem.

A side effect of the change was reload now sometimes tries to push a constant symbolic reference
to data into readonly memory.  The 32-bit HP linker doesn't like these references.  Thus, the change
to pa_cannot_force_const_mem.

Tested on hppa2.0w-hp-hpux11.11, hppa64-hp-hpux11.11 and hppa-unknown-linu-gnu.  Committed
to trunk and 4.9 branch.

Dave
--
John David Anglin	dave.anglin@bell.net
2015-02-13  John David Anglin  <danglin@gcc.gnu.org>

	* config/pa/constraints.md: Change "Q" and "T" constraints to memory
	constraints.
	* config/pa/pa.c (pa_cannot_force_const_mem): Don't allow constant
	symbolic references to data to be forced to constant memory on the
	SOM target.

Comments

Richard Henderson Feb. 13, 2015, 5:08 p.m. UTC | #1
On 02/13/2015 05:22 AM, John David Anglin wrote:
> +  /* Reload sometimes tries to put const data symbolic operands in
> +     readonly memory.  The HP SOM linker doesn't allow symbolic data
> +     in readonly memory.  */
> +  if (TARGET_SOM
> +      && !function_label_operand (x, VOIDmode)
> +      && symbolic_operand (x, VOIDmode))
> +    return true;

You probably want to remove the SOM test.  Even if ELF can represent this, it
will lead to DT_TEXTREL and relocations against the read-only memory.


r~
John David Anglin Feb. 14, 2015, 2:50 p.m. UTC | #2
On 2015-02-13, at 12:08 PM, Richard Henderson wrote:

> On 02/13/2015 05:22 AM, John David Anglin wrote:
>> +  /* Reload sometimes tries to put const data symbolic operands in
>> +     readonly memory.  The HP SOM linker doesn't allow symbolic data
>> +     in readonly memory.  */
>> +  if (TARGET_SOM
>> +      && !function_label_operand (x, VOIDmode)
>> +      && symbolic_operand (x, VOIDmode))
>> +    return true;
> 
> You probably want to remove the SOM test.  Even if ELF can represent this, it
> will lead to DT_TEXTREL and relocations against the read-only memory.


Unfortunately, this creates new problems.  When there is a constant offset that won't fit
in 14 bits, we ICE.  I think this could be improved to 21 bits but it's tough to load an operand
with a larger offset with just one register, particularly when generating PIC code.  I need
to research what happens on SOM with large offsets.

Possibly the constant can somehow be forced into the data section where the relocations
aren't a problem?

Dave
--
John David Anglin	dave.anglin@bell.net
Richard Henderson Feb. 16, 2015, 4:38 p.m. UTC | #3
On 02/14/2015 06:50 AM, John David Anglin wrote:
> Possibly the constant can somehow be forced into the data section where the relocations
> aren't a problem?

Hmm.  It looks like we might already do that.  See default_select_rtx_section.


r~
John David Anglin Feb. 16, 2015, 6:47 p.m. UTC | #4
On 2015-02-16, at 11:38 AM, Richard Henderson wrote:

>> 
>> Possibly the constant can somehow be forced into the data section where the relocations
>> aren't a problem?
> 
> Hmm.  It looks like we might already do that.  See default_select_rtx_section.

Thanks, I see the problem.  default_reloc_rw_mask returns 0 when not generating PIC
code, so rtx went to readonly_data_section.  I was thinking that pa_select_section was
somehow broken.

Dave
--
John David Anglin	dave.anglin@bell.net
diff mbox

Patch

Index: config/pa/constraints.md
===================================================================
--- config/pa/constraints.md	(revision 220598)
+++ config/pa/constraints.md	(working copy)
@@ -106,7 +106,7 @@ 
   (and (match_code "mem")
        (match_test "IS_LO_SUM_DLT_ADDR_P (XEXP (op, 0))")))
 
-(define_constraint "Q"
+(define_memory_constraint "Q"
   "A memory operand that can be used as the destination operand of an
    integer store, or the source operand of an integer load.  That is
    any memory operand that isn't a symbolic, indexed or lo_sum memory
@@ -122,7 +122,7 @@ 
   (and (match_code "mem")
        (match_test "IS_INDEX_ADDR_P (XEXP (op, 0))")))
 
-(define_constraint "T"
+(define_memory_constraint "T"
   "A memory operand for floating-point loads and stores."
   (match_test "floating_point_store_memory_operand (op, mode)"))
 
Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c	(revision 220598)
+++ config/pa/pa.c	(working copy)
@@ -1569,6 +1569,14 @@ 
 static bool
 pa_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
 {
+  /* Reload sometimes tries to put const data symbolic operands in
+     readonly memory.  The HP SOM linker doesn't allow symbolic data
+     in readonly memory.  */
+  if (TARGET_SOM
+      && !function_label_operand (x, VOIDmode)
+      && symbolic_operand (x, VOIDmode))
+    return true;
+
   return tls_referenced_p (x);
 }