diff mbox series

Fix PR rtl-optimization/89490

Message ID AM6PR07MB4037B2F57E5862FC5B15E438E4740@AM6PR07MB4037.eurprd07.prod.outlook.com
State New
Headers show
Series Fix PR rtl-optimization/89490 | expand

Commit Message

Bernd Edlinger Feb. 27, 2019, 7:44 p.m. UTC
Hi!


This patch fixes a P1 regression due to the recently introduced
more aggressive constant string merging, which does not work
correctly in object blocks consisting of STRING_CST w/o proper
zero-termination.

Fixed by avoiding creation of block objects for objects located
in mergeable sections.


Bootstrapped and reg-tested on x86_64-pc-linux-gnu,
powerpc64le-linux, and powerpc64-linux (-m32/-m64)
with help from Jakub.

Is it OK for trunk?


Thanks
Bernd.

Comments

Jakub Jelinek Feb. 27, 2019, 7:47 p.m. UTC | #1
On Wed, Feb 27, 2019 at 07:44:40PM +0000, Bernd Edlinger wrote:
> This patch fixes a P1 regression due to the recently introduced
> more aggressive constant string merging, which does not work
> correctly in object blocks consisting of STRING_CST w/o proper
> zero-termination.
> 
> Fixed by avoiding creation of block objects for objects located
> in mergeable sections.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu,
> powerpc64le-linux, and powerpc64-linux (-m32/-m64)
> with help from Jakub.
> 
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.

> 2019-02-27  Bernd Edlinger  <bernd.edlinger@hotmail.de>
> 
> 	PR rtl-optimization/89490
> 	* varasm.c (get_block_for_section): Bail out for mergeable sections.
> 	(default_use_anchors_for_symbol_p, output_object_block): Assert the
> 	block section is not mergeable.

Ok, thanks.

	Jakub
diff mbox series

Patch

2019-02-27  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR rtl-optimization/89490
	* varasm.c (get_block_for_section): Bail out for mergeable sections.
	(default_use_anchors_for_symbol_p, output_object_block): Assert the
	block section is not mergeable.

--- gcc/varasm.c.orig	2019-02-21 23:50:24.000000000 +0100
+++ gcc/varasm.c	2019-02-27 11:33:32.741967812 +0100
@@ -363,7 +363,11 @@  use_object_blocks_p (void)
 
 /* Return the object_block structure for section SECT.  Create a new
    structure if we haven't created one already.  Return null if SECT
-   itself is null.  */
+   itself is null.  Return also null for mergeable sections since
+   section anchors can't be used in mergeable sections anyway,
+   because the linker might move objects around, and using the
+   object blocks infrastructure in that case is both a waste and a
+   maintenance burden.  */
 
 static struct object_block *
 get_block_for_section (section *sect)
@@ -373,6 +377,9 @@  get_block_for_section (section *sect)
   if (sect == NULL)
     return NULL;
 
+  if (sect->common.flags & SECTION_MERGE)
+    return NULL;
+
   object_block **slot
     = object_block_htab->find_slot_with_hash (sect, hash_section (sect),
 					      INSERT);
@@ -7014,14 +7021,13 @@  default_asm_output_anchor (rtx symbol)
 bool
 default_use_anchors_for_symbol_p (const_rtx symbol)
 {
-  section *sect;
   tree decl;
+  section *sect = SYMBOL_REF_BLOCK (symbol)->sect;
 
-  /* Don't use anchors for mergeable sections.  The linker might move
-     the objects around.  */
-  sect = SYMBOL_REF_BLOCK (symbol)->sect;
-  if (sect->common.flags & SECTION_MERGE)
-    return false;
+  /* This function should only be called with non-zero SYMBOL_REF_BLOCK,
+     furthermore get_block_for_section should not create object blocks
+     for mergeable sections.  */
+  gcc_checking_assert (sect && !(sect->common.flags & SECTION_MERGE));
 
   /* Don't use anchors for small data sections.  The small data register
      acts as an anchor for such sections.  */
@@ -7630,6 +7636,7 @@  output_object_block (struct object_block
   else
     switch_to_section (block->sect);
 
+  gcc_checking_assert (!(block->sect->common.flags & SECTION_MERGE));
   assemble_align (block->alignment);
 
   /* Define the values of all anchors relative to the current section