From 68cd067f31c13523a90ad3bdb2db8fac5c674da7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 23 Jun 2010 03:33:15 -0400 Subject: [PATCH] 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) --- basis/compiler/cfg/builder/blocks/blocks.factor | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/basis/compiler/cfg/builder/blocks/blocks.factor b/basis/compiler/cfg/builder/blocks/blocks.factor index 293c3fe09b..82af0f9b30 100644 --- a/basis/compiler/cfg/builder/blocks/blocks.factor +++ b/basis/compiler/cfg/builder/blocks/blocks.factor @@ -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 ;