diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2019-04-13 05:55:34 -0300 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-04-25 08:35:13 +0930 |
commit | 38c3873e5d53902cf9cc73a4a5a05adf371296a6 (patch) | |
tree | c833fb3857be146bd9f1085b943b3a5acc31b842 /gas/expr.c | |
parent | 1670072efb31e82d52d408940062860e2835d79c (diff) | |
download | binutils-38c3873e5d53902cf9cc73a4a5a05adf371296a6.zip binutils-38c3873e5d53902cf9cc73a4a5a05adf371296a6.tar.gz binutils-38c3873e5d53902cf9cc73a4a5a05adf371296a6.tar.bz2 |
Speed up locview resolution with relaxable frags
Targets such as xtensa incur a much higher overhead to resolve
location view numbers than e.g. x86, because the expressions used to
compute view numbers cannot be resolved soon enough.
Each view number is computed by incrementing the previous view, if
they are both at the same address, or by resetting it to zero
otherwise. If PV is the previous view number, PL is its location, and
NL is the location of the next view, its number is computed by
evaluating NV = !(NL > PL) * (PV + 1).
set_or_check_view uses resolve_expression to decide whether portions
of this expression can be simplified to constants. The (NL > PL)
subexpression is one that can often be resolved to a constant,
breaking chains of view number computations at instructions of nonzero
length, but not after alignment that might be unnecessary.
Alas, when nearly every frag ends with a relaxable instruction,
frag_offset_fixed_p will correctly fail to determine a known offset
between two unresolved addresses in neighboring frags, so the
unresolved symbolic operation will be constructed and used in the
computation of most view numbers. This results in very deep
expressions.
As view numbers get referenced in location view lists, each operand in
the list goes through symbol_clone_if_forward_ref, which recurses on
every subexpression. If each view number were to be referenced, this
would exhibit O(n^2) behavior, where n is the depth of the view number
expressions, i.e., the length of view number sequences without an
early resolution that cuts the expression short.
This patch enables address compares used by view numbering to be
resolved even when exact offsets are not known, using new logic to
determine when the location either remained the same or changed for
sure, even with the possibility of relaxation. This enables most view
number expressions to be resolved with a small, reasonable depth.
PR gas/24444
* frags.c (frag_gtoffset_p): New.
* frags.h (frag_gtoffset_p): Declare it.
* expr.c (resolve_expression): Use it.
Diffstat (limited to 'gas/expr.c')
-rw-r--r-- | gas/expr.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -2179,7 +2179,10 @@ resolve_expression (expressionS *expressionP) || op == O_lt || op == O_le || op == O_ge || op == O_gt) && seg_left == seg_right && (finalize_syms - || frag_offset_fixed_p (frag_left, frag_right, &frag_off)) + || frag_offset_fixed_p (frag_left, frag_right, &frag_off) + || (op == O_gt + && frag_gtoffset_p (left, frag_left, + right, frag_right, &frag_off))) && (seg_left != reg_section || left == right) && (seg_left != undefined_section || add_symbol == op_symbol))) { |