aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorJames Greenhalgh <james.greenhalgh@arm.com>2016-12-02 14:31:10 +0000
committerJames Greenhalgh <jgreenhalgh@gcc.gnu.org>2016-12-02 14:31:10 +0000
commit04c452f40ba95e15a76762e4bb5767d15cf8b322 (patch)
tree0805d0e50f69a67e6af48f94b97693ba9dfc5282 /gcc/varasm.c
parent474bbda1675d35ab6f78ffdf20ee091f8402d185 (diff)
downloadgcc-04c452f40ba95e15a76762e4bb5767d15cf8b322.zip
gcc-04c452f40ba95e15a76762e4bb5767d15cf8b322.tar.gz
gcc-04c452f40ba95e15a76762e4bb5767d15cf8b322.tar.bz2
[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
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index f8af0c1..f3cd70a 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -3942,6 +3942,29 @@ output_constant_pool_1 (struct constant_descriptor_rtx *desc,
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.
Emit referenced deferred strings. */
@@ -4060,6 +4083,11 @@ output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
case we do not need to output the constant. */
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
ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool->offset);
#endif