This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fixing jumps reachability after block reordering


+++ Ian Lance Taylor [05/07/07 17:48 -0700]:
> "Gregory B. Prokopski" <gadek@debian.org> writes:
> 
> > One of the operations I need to perform is to reorder basic blocks in a
> > particular manner.  This works fine for example on i386 and other that have
> > HAS_LONG_COND_BRANCH, HAS_LONG_UNCOND_BRANCH set.  However on platforms like
> > PPC, after the reordering, some branches are trying to reach destinations
> > beyond their reach and I get errors during the final assembly.
> 
> The hot/cold block partitioning code, -freorder-blocks-and-partition,
> faces a similar problem.  How do they solve it?

They only care about the edges that cross hot/cold sections boundaries.
In my case, for all I care, the code of whole function can be in the hot
section.

> > For each function that has basic blocks reordered for code-copying,
> >   Scan all the insn's, find all jumps,
> >     For each jump check its destination label, and
> >       1. compute the distance between the jump and the label
> >         (if possible use insn_lengths[] form final.c, or build it yourself
> >         using get_attr_length())
> >       2. compare the distance with what can be reached using the Mode
> >         (GET_MODE_SIZE, exact_log2())
> >       3. if Mode won't reach the destination, create an extra BB with an
> >         unconditional or indirect jump to the label (like bb-reorder.c)
> > 	and redirect the original jump to it.
> 
> But you seem to be within a single function, so I don't understand why
> you have any trouble at all.  Why doesn't the shorten_branches pass
> work for you?

I reorder the basic blocks in passes.c, right after compute_alignmnets ().
I added a call to shorten_branches(NULL_RTX) right after my BB reordering,
but it didn't change a thing, and I am still getting as errors:

libsablevm.s: Assembler messages:
libsablevm.s:56077: Error: operand out of range (91824 not between -32768 and
32767)
libsablevm.s:71896: Error: operand out of range (-38472 not between -32768
and 32767)
libsablevm.s:97418: Error: operand out of range (-51652 not between -32768
and 32767)

Almost a hundred of these.  I would need a way to debug this problem, which
means I'd like to detect this problem earlier, say, when I do the block
reordering.  I thought I could do it with the algorigthm I described above.

G.

-- 
Gregory B. Prokopski       <gadek@debian.org>
Sable Research Group       http://www.sable.mcgill.ca
Montreal, Quebec, Canada


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]