This is the mail archive of the
mailing list for the GCC project.
Fixing jumps reachability after block reordering
- From: "Gregory B. Prokopski" <gadek at debian dot org>
- To: GCC <gcc at gcc dot gnu dot org>
- Date: Thu, 5 Jul 2007 16:57:24 -0400
- Subject: Fixing jumps reachability after block reordering
I am working on adding support for code-copying to GCC that can be used to
safely speed up interpreter-based VMs, as will be presented at GCC Summit:
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 draft of a solution I came up with after a few days of digging in the
existing code is this:
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
2. compare the distance with what can be reached using the Mode
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.
Is there an esier way of doing it? (maybe there's mechanisms in GCC that do
it already?) What am I missing? Any similar code in GCC I should look at?
Gregory B. Prokopski <email@example.com>
Sable Research Group http://www.sable.mcgill.ca
Montreal, Quebec, Canada