xtensa trampolines relaxation optimization caused the following build
errors:
Error: operand 1 of 'j' has out of range value '131643'
Error: operand 1 of 'j' has out of range value '
4294836162'
Error: operand 1 of 'j' has out of range value '
4294836072'
Extra condition 'abs (addr - trampaddr) < J_RANGE / 2' for trampoline
selection results in regressions: when relaxable jump is little longer
than J_RANGE so that single trampoline makes two new jumps, one longer
than J_RANGE / 2 and one shorter, correct trampoline cannot be found.
Drop that condition.
Upstream status: patch submitted.
Fix squashed into the optimization patch.
Fixes:
http://autobuild.buildroot.net/results/
5ba7d18262ce6a2dfd69db07d064a971267f1128/
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Backported from: b76f99d702c3501ac320396ea06bc7f9237173c3
Changes to ChangeLog are dropped.
- gas/config/tc-xtensa.c | 221 +++++++++++++++++++++++++++++++++++++++++++------
- 1 file changed, 194 insertions(+), 27 deletions(-)
+ gas/config/tc-xtensa.c | 220 +++++++++++++++++++++++++++++++++++++++++++------
+ 1 file changed, 194 insertions(+), 26 deletions(-)
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
-index 3e85b69..b1827fa 100644
+index 3e85b69..31c0b6b 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -8785,6 +8785,154 @@ static long relax_frag_for_align (fragS *, long);
/* Return the number of bytes added to this fragment, given that the
input has been stretched already by "stretch". */
-@@ -8896,35 +9044,43 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -8896,35 +9044,42 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
case RELAX_TRAMPOLINE:
if (fragP->tc_frag_data.relax_seen)
{
+
+ trampaddr = fragP->fr_address + fragP->fr_fix;
+
-+ if ((addr + J_RANGE < trampaddr) ||
-+ abs (addr - trampaddr) < J_RANGE / 2)
++ if (addr + J_RANGE < trampaddr)
continue;
- target = S_GET_VALUE (s);
- addr = fixP->fx_frag->fr_address;
if (delta > J_RANGE || delta < -1 * J_RANGE)
{ /* Found an out-of-range jump; scan the list of trampolines for the best match. */
struct trampoline_seg *ts = find_trampoline_seg (now_seg);
-@@ -8978,14 +9134,13 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -8978,14 +9133,13 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
}
if (tf->fragP == fragP)
{
new_stretch += init_trampoline_frag (tf);
offset = fragP->fr_fix; /* Where to assemble the j insn. */
-@@ -9009,10 +9164,20 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -9009,10 +9163,20 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
newfixP->tc_fix_data.X_add_symbol = lsym;
newfixP->tc_fix_data.X_add_number = offset;
newfixP->tc_fix_data.slot = slot;
/* Adjust the jump around this trampoline (if present). */
if (tf->fixP != NULL)
{
-@@ -9027,6 +9192,8 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -9027,6 +9191,8 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
fragP->fr_subtype = 0;
/* Remove from the trampoline_list. */
prev->next = tf->next;
Backported from: b76f99d702c3501ac320396ea06bc7f9237173c3
Changes to ChangeLog are dropped.
- gas/config/tc-xtensa.c | 221 +++++++++++++++++++++++++++++++++++++++++++------
- 1 file changed, 194 insertions(+), 27 deletions(-)
+ gas/config/tc-xtensa.c | 220 +++++++++++++++++++++++++++++++++++++++++++------
+ 1 file changed, 194 insertions(+), 26 deletions(-)
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
-index 3e85b69..b1827fa 100644
+index 3e85b69..31c0b6b 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -8785,6 +8785,154 @@ static long relax_frag_for_align (fragS *, long);
/* Return the number of bytes added to this fragment, given that the
input has been stretched already by "stretch". */
-@@ -8896,35 +9044,43 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -8896,35 +9044,42 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
case RELAX_TRAMPOLINE:
if (fragP->tc_frag_data.relax_seen)
{
+
+ trampaddr = fragP->fr_address + fragP->fr_fix;
+
-+ if ((addr + J_RANGE < trampaddr) ||
-+ abs (addr - trampaddr) < J_RANGE / 2)
++ if (addr + J_RANGE < trampaddr)
continue;
- target = S_GET_VALUE (s);
- addr = fixP->fx_frag->fr_address;
if (delta > J_RANGE || delta < -1 * J_RANGE)
{ /* Found an out-of-range jump; scan the list of trampolines for the best match. */
struct trampoline_seg *ts = find_trampoline_seg (now_seg);
-@@ -8978,14 +9134,13 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -8978,14 +9133,13 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
}
if (tf->fragP == fragP)
{
new_stretch += init_trampoline_frag (tf);
offset = fragP->fr_fix; /* Where to assemble the j insn. */
-@@ -9009,10 +9164,20 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -9009,10 +9163,20 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
newfixP->tc_fix_data.X_add_symbol = lsym;
newfixP->tc_fix_data.X_add_number = offset;
newfixP->tc_fix_data.slot = slot;
/* Adjust the jump around this trampoline (if present). */
if (tf->fixP != NULL)
{
-@@ -9027,6 +9192,8 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
+@@ -9027,6 +9191,8 @@ xtensa_relax_frag (fragS *fragP, long stretch, int *stretched_p)
fragP->fr_subtype = 0;
/* Remove from the trampoline_list. */
prev->next = tf->next;