Commit 04c452f4 by James Greenhalgh Committed by James Greenhalgh

[Patch 2/2 PR78561] Recalculate constant pool size before emitting it

gcc/

	PR rtl-optimization/78561
	* varasm.c (recompute_pool_offsets): New.
	(output_constant_pool): Call it.

gcc/testsuite/

	PR rtl-optimization/78561
	* gcc.target/aarch64/pr78561.c: New.

From-SVN: r243183
parent 474bbda1
2016-12-02 James Greenhalgh <james.greenhalgh@arm.com> 2016-12-02 James Greenhalgh <james.greenhalgh@arm.com>
PR rtl-optimization/78561 PR rtl-optimization/78561
* varasm.c (recompute_pool_offsets): New.
(output_constant_pool): Call it.
2016-12-02 James Greenhalgh <james.greenhalgh@arm.com>
PR rtl-optimization/78561
* config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p) Rename * config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p) Rename
get_pool_size to get_pool_size_upper_bound. get_pool_size to get_pool_size_upper_bound.
(rs6000_stack_info): Likewise. (rs6000_stack_info): Likewise.
2016-12-02 James Greenhalgh <james.greenhalgh@arm.com>
PR rtl-optimization/78561
* gcc.target/aarch64/pr78561.c: New.
2016-12-02 Bin Cheng <bin.cheng@arm.com> 2016-12-02 Bin Cheng <bin.cheng@arm.com>
* gcc.dg/fold-bopcond-1.c: New test. * gcc.dg/fold-bopcond-1.c: New test.
......
...@@ -3942,6 +3942,29 @@ output_constant_pool_1 (struct constant_descriptor_rtx *desc, ...@@ -3942,6 +3942,29 @@ output_constant_pool_1 (struct constant_descriptor_rtx *desc,
return; return;
} }
/* Recompute the offsets of entries in POOL, and the overall size of
POOL. Do this after calling mark_constant_pool to ensure that we
are computing the offset values for the pool which we will actually
emit. */
static void
recompute_pool_offsets (struct rtx_constant_pool *pool)
{
struct constant_descriptor_rtx *desc;
pool->offset = 0;
for (desc = pool->first; desc ; desc = desc->next)
if (desc->mark)
{
/* Recalculate offset. */
unsigned int align = desc->align;
pool->offset += (align / BITS_PER_UNIT) - 1;
pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);
desc->offset = pool->offset;
pool->offset += GET_MODE_SIZE (desc->mode);
}
}
/* Mark all constants that are referenced by SYMBOL_REFs in X. /* Mark all constants that are referenced by SYMBOL_REFs in X.
Emit referenced deferred strings. */ Emit referenced deferred strings. */
...@@ -4060,6 +4083,11 @@ output_constant_pool (const char *fnname ATTRIBUTE_UNUSED, ...@@ -4060,6 +4083,11 @@ output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
case we do not need to output the constant. */ case we do not need to output the constant. */
mark_constant_pool (); mark_constant_pool ();
/* Having marked the constant pool entries we'll actually emit, we
now need to rebuild the offset information, which may have become
stale. */
recompute_pool_offsets (pool);
#ifdef ASM_OUTPUT_POOL_PROLOGUE #ifdef ASM_OUTPUT_POOL_PROLOGUE
ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool->offset); ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool->offset);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment