Commit 3373692b by Jakub Jelinek Committed by Jakub Jelinek

function.c (block_fragments_nreverse, [...]): New functions.

	* function.c (block_fragments_nreverse, blocks_nreverse_all): New
	functions.
	(reorder_blocks): Use blocks_nreverse_all instead of blocks_nreverse.
	(reorder_blocks_1): Assert BLOCK_FRAGMENT_ORIGIN is NULL.  Don't
	call block_nreverse here.
	(blocks_nreverse): Rename decl temporary to block.

From-SVN: r163292
parent 4681303c
2010-08-17 Jakub Jelinek <jakub@redhat.com>
* function.c (block_fragments_nreverse, blocks_nreverse_all): New
functions.
(reorder_blocks): Use blocks_nreverse_all instead of blocks_nreverse.
(reorder_blocks_1): Assert BLOCK_FRAGMENT_ORIGIN is NULL. Don't
call block_nreverse here.
(blocks_nreverse): Rename decl temporary to block.
2010-08-16 Bernd Schmidt <bernds@codesourcery.com> 2010-08-16 Bernd Schmidt <bernds@codesourcery.com>
* config/arm/thumb2.md (thumb2_notsi_shiftsi, * config/arm/thumb2.md (thumb2_notsi_shiftsi,
......
...@@ -3953,6 +3953,46 @@ generate_setjmp_warnings (void) ...@@ -3953,6 +3953,46 @@ generate_setjmp_warnings (void)
} }
/* Reverse the order of elements in the fragment chain T of blocks,
and return the new head of the chain (old last element). */
static tree
block_fragments_nreverse (tree t)
{
tree prev = 0, block, next;
for (block = t; block; block = next)
{
next = BLOCK_FRAGMENT_CHAIN (block);
BLOCK_FRAGMENT_CHAIN (block) = prev;
prev = block;
}
return prev;
}
/* Reverse the order of elements in the chain T of blocks,
and return the new head of the chain (old last element).
Also do the same on subblocks and reverse the order of elements
in BLOCK_FRAGMENT_CHAIN as well. */
static tree
blocks_nreverse_all (tree t)
{
tree prev = 0, block, next;
for (block = t; block; block = next)
{
next = BLOCK_CHAIN (block);
BLOCK_CHAIN (block) = prev;
BLOCK_SUBBLOCKS (block) = blocks_nreverse_all (BLOCK_SUBBLOCKS (block));
if (BLOCK_FRAGMENT_CHAIN (block)
&& BLOCK_FRAGMENT_ORIGIN (block) == NULL_TREE)
BLOCK_FRAGMENT_CHAIN (block)
= block_fragments_nreverse (BLOCK_FRAGMENT_CHAIN (block));
prev = block;
}
return prev;
}
/* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END}, /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END},
and create duplicate blocks. */ and create duplicate blocks. */
/* ??? Need an option to either create block fragments or to create /* ??? Need an option to either create block fragments or to create
...@@ -3979,7 +4019,7 @@ reorder_blocks (void) ...@@ -3979,7 +4019,7 @@ reorder_blocks (void)
/* Recreate the block tree from the note nesting. */ /* Recreate the block tree from the note nesting. */
reorder_blocks_1 (get_insns (), block, &block_stack); reorder_blocks_1 (get_insns (), block, &block_stack);
BLOCK_SUBBLOCKS (block) = blocks_nreverse (BLOCK_SUBBLOCKS (block)); BLOCK_SUBBLOCKS (block) = blocks_nreverse_all (BLOCK_SUBBLOCKS (block));
VEC_free (tree, heap, block_stack); VEC_free (tree, heap, block_stack);
} }
...@@ -4011,9 +4051,8 @@ reorder_blocks_1 (rtx insns, tree current_block, VEC(tree,heap) **p_block_stack) ...@@ -4011,9 +4051,8 @@ reorder_blocks_1 (rtx insns, tree current_block, VEC(tree,heap) **p_block_stack)
tree block = NOTE_BLOCK (insn); tree block = NOTE_BLOCK (insn);
tree origin; tree origin;
origin = (BLOCK_FRAGMENT_ORIGIN (block) gcc_assert (BLOCK_FRAGMENT_ORIGIN (block) == NULL_TREE);
? BLOCK_FRAGMENT_ORIGIN (block) origin = block;
: block);
/* If we have seen this block before, that means it now /* If we have seen this block before, that means it now
spans multiple address regions. Create a new fragment. */ spans multiple address regions. Create a new fragment. */
...@@ -4050,8 +4089,6 @@ reorder_blocks_1 (rtx insns, tree current_block, VEC(tree,heap) **p_block_stack) ...@@ -4050,8 +4089,6 @@ reorder_blocks_1 (rtx insns, tree current_block, VEC(tree,heap) **p_block_stack)
else if (NOTE_KIND (insn) == NOTE_INSN_BLOCK_END) else if (NOTE_KIND (insn) == NOTE_INSN_BLOCK_END)
{ {
NOTE_BLOCK (insn) = VEC_pop (tree, *p_block_stack); NOTE_BLOCK (insn) = VEC_pop (tree, *p_block_stack);
BLOCK_SUBBLOCKS (current_block)
= blocks_nreverse (BLOCK_SUBBLOCKS (current_block));
current_block = BLOCK_SUPERCONTEXT (current_block); current_block = BLOCK_SUPERCONTEXT (current_block);
} }
} }
...@@ -4064,12 +4101,12 @@ reorder_blocks_1 (rtx insns, tree current_block, VEC(tree,heap) **p_block_stack) ...@@ -4064,12 +4101,12 @@ reorder_blocks_1 (rtx insns, tree current_block, VEC(tree,heap) **p_block_stack)
tree tree
blocks_nreverse (tree t) blocks_nreverse (tree t)
{ {
tree prev = 0, decl, next; tree prev = 0, block, next;
for (decl = t; decl; decl = next) for (block = t; block; block = next)
{ {
next = BLOCK_CHAIN (decl); next = BLOCK_CHAIN (block);
BLOCK_CHAIN (decl) = prev; BLOCK_CHAIN (block) = prev;
prev = decl; prev = block;
} }
return prev; return prev;
} }
......
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