compiler.cfg.builder: if there is a conditional where every branch is known to throw an error, don't process any of the (unreachable) code after the conditional, since this can confuse analysis (reported by Daniel Ehrenberg)

db4
Slava Pestov 2010-06-23 03:33:15 -04:00
parent d2bef80a19
commit 68cd067f31
1 changed files with 6 additions and 11 deletions

View File

@ -60,19 +60,14 @@ IN: compiler.cfg.builder.blocks
: set-successors ( branches -- )
! Set the successor of each branch's final basic block to the
! current block.
basic-block get dup [
'[ [ [ _ ] dip first successors>> push ] when* ] each
] [ 2drop ] if ;
: merge-heights ( branches -- )
! If all elements are f, that means every branch ended with a backward
! jump so the height is irrelevant since this block is unreachable.
[ ] find nip [ second current-height set ] [ end-basic-block ] if* ;
[ [ [ basic-block get ] dip first successors>> push ] when* ] each ;
: emit-conditional ( branches -- )
! branches is a sequence of pairs as above
end-basic-block
[ merge-heights begin-basic-block ]
[ set-successors ]
bi ;
dup [ ] find nip dup [
second current-height set
begin-basic-block
set-successors
] [ 2drop ] if ;