compiler.cfg.stacks.finalize: only insert blocks if they aren't empty

Previously, a lot of empty blocks were added too.
char-rename
Björn Lindqvist 2016-09-01 01:50:40 +02:00
parent c26379ea7e
commit f7542e95a9
3 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,5 @@
USING: assocs compiler.cfg help.markup help.syntax ;
USING: assocs compiler.cfg compiler.cfg.instructions help.markup
help.syntax ;
IN: compiler.cfg.stacks.finalize
HELP: inserting-peeks
@ -24,7 +25,7 @@ HELP: finalize-stack-shuffling
HELP: visit-edge
{ $values { "from" basic-block } { "to" basic-block } }
{ $description "If both blocks are subroutine calls, don't bother computing anything." } ;
{ $description "If required, insert a block containing " { $link ##peek } " and " { $link ##replace } " instructions on the edge between the 'from' and 'to' block. If no such instructions are needed, then no block is inserted." } ;
ARTICLE: "compiler.cfg.stacks.finalize" "Stack finalization"
"This pass inserts peeks and replaces." ;

View File

@ -5,10 +5,9 @@ compiler.cfg.utilities kernel sequences tools.test ;
IN: compiler.cfg.stacks.finalize.tests
{
T{ ##branch f f }
T{ ##branch f f }
"there" "hi"
} [
V{ } clone 1 insns>block V{ } clone 2 insns>block
V{ "hi" } clone 1 insns>block V{ "there" } clone 2 insns>block
2dup connect-bbs 2dup visit-edge
[ successors>> first instructions>> first ]
[ predecessors>> first instructions>> first ] bi*

View File

@ -37,10 +37,10 @@ ERROR: bad-peek dst loc ;
[ dup n>> 0 < [ 2drop ] [ ##replace, ] if ] each-insertion ;
: visit-edge ( from to -- )
2dup [ kill-block?>> ] both? [ 2drop ] [
2dup [ [ insert-replaces ] [ insert-peeks ] 2bi ##branch, ] V{ } make
2dup [ [ insert-replaces ] [ insert-peeks ] 2bi ##branch, ] V{ } make
dup length 1 > [
insert-basic-block
] if ;
] [ 3drop ] if ;
: visit-block ( bb -- )
[ predecessors>> ] keep '[ _ visit-edge ] each ;