Commit fc289cd1 by Jim Wilson

(identify_blocks): Handle case where no block nodes exist.

(identify_blocks): Handle case where no block nodes
exist.  Use xmalloc not alloca for block_vector.
(reorder_blocks): New argument top_block.  Handle case where no
block nodes exist.  Always clear BLOCK_SUBBLOCKS (block) when
adding it to the block tree.
(all_blocks): Handle case where vector is zero. Store current
block at offset 0 in vector, not n_blocks.  Don't count current
block twice in n_blocks.

From-SVN: r1797
parent 715e6efb
...@@ -3552,14 +3552,21 @@ identify_blocks (top_block, insns) ...@@ -3552,14 +3552,21 @@ identify_blocks (top_block, insns)
tree top_block; tree top_block;
rtx insns; rtx insns;
{ {
int n_blocks = all_blocks (top_block, 0); int n_blocks;
tree *block_vector = (tree *) alloca (n_blocks * sizeof (tree)); tree *block_vector;
int *block_stack = (int *) alloca (n_blocks * sizeof (int)); int *block_stack;
int depth = 0; int depth = 0;
int next_block_number = 0; int next_block_number = 0;
int current_block_number = 0; int current_block_number = 0;
rtx insn; rtx insn;
if (top_block == 0)
return 0;
n_blocks = all_blocks (top_block, 0);
block_vector = (tree *) xmalloc (n_blocks * sizeof (tree));
block_stack = (int *) alloca (n_blocks * sizeof (int));
all_blocks (top_block, block_vector); all_blocks (top_block, block_vector);
for (insn = insns; insn; insn = NEXT_INSN (insn)) for (insn = insns; insn; insn = NEXT_INSN (insn))
...@@ -3584,16 +3591,24 @@ identify_blocks (top_block, insns) ...@@ -3584,16 +3591,24 @@ identify_blocks (top_block, insns)
/* Given BLOCK_VECTOR which was returned by identify_blocks, /* Given BLOCK_VECTOR which was returned by identify_blocks,
and a revised instruction chain, rebuild the tree structure and a revised instruction chain, rebuild the tree structure
of BLOCK nodes to correspond to the new order of RTL. of BLOCK nodes to correspond to the new order of RTL.
The new block tree is inserted below TOP_BLOCK.
Returns the current top-level block. */ Returns the current top-level block. */
tree tree
reorder_blocks (block_vector, insns) reorder_blocks (block_vector, top_block, insns)
tree *block_vector; tree *block_vector;
tree top_block;
rtx insns; rtx insns;
{ {
tree current_block = block_vector[0]; tree current_block = top_block;
rtx insn; rtx insn;
if (block_vector == 0)
return top_block;
/* Prune the old tree away, so that it doesn't get in the way. */
BLOCK_SUBBLOCKS (current_block) = 0;
for (insn = insns; insn; insn = NEXT_INSN (insn)) for (insn = insns; insn; insn = NEXT_INSN (insn))
if (GET_CODE (insn) == NOTE) if (GET_CODE (insn) == NOTE)
{ {
...@@ -3603,8 +3618,7 @@ reorder_blocks (block_vector, insns) ...@@ -3603,8 +3618,7 @@ reorder_blocks (block_vector, insns)
/* If we have seen this block before, copy it. */ /* If we have seen this block before, copy it. */
if (TREE_ASM_WRITTEN (block)) if (TREE_ASM_WRITTEN (block))
block = copy_node (block); block = copy_node (block);
else BLOCK_SUBBLOCKS (block) = 0;
BLOCK_SUBBLOCKS (block) = 0;
TREE_ASM_WRITTEN (block) = 1; TREE_ASM_WRITTEN (block) = 1;
BLOCK_SUPERCONTEXT (block) = current_block; BLOCK_SUPERCONTEXT (block) = current_block;
BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (current_block); BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (current_block);
...@@ -3654,12 +3668,13 @@ all_blocks (block, vector) ...@@ -3654,12 +3668,13 @@ all_blocks (block, vector)
TREE_ASM_WRITTEN (block) = 0; TREE_ASM_WRITTEN (block) = 0;
/* Record this block. */ /* Record this block. */
vector[n_blocks++] = block; if (vector)
vector[0] = block;
/* Record the subblocks, and their subblocks. */ /* Record the subblocks, and their subblocks. */
for (subblocks = BLOCK_SUBBLOCKS (block); for (subblocks = BLOCK_SUBBLOCKS (block);
subblocks; subblocks = BLOCK_CHAIN (subblocks)) subblocks; subblocks = BLOCK_CHAIN (subblocks))
n_blocks += all_blocks (subblocks, vector + n_blocks); n_blocks += all_blocks (subblocks, vector ? vector + n_blocks : 0);
return n_blocks; return n_blocks;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment