~jojo/Carth

dac5a6dc7e7fc75c7b78388dc4071a75039a8408 — JoJo 1 year, 10 months ago a62b1e1
Fix incorrect from-label used in phi-node of decision switch
1 files changed, 7 insertions(+), 4 deletions(-)

M src/Codegen.hs
M src/Codegen.hs => src/Codegen.hs +7 -4
@@ 539,13 539,16 @@ genDecisionSwitch selector cs def tbody selections = do
    let litIxInt = LLConst.Int ixBits . fromIntegral
    let dests' = zip (map litIxInt variantIxs) variantLs
    commitToNewBlock (switch mVariantIx defaultL dests') defaultL
    v <- getLocal =<< genDecisionTree tbody def selections'
    let genDecisionTree' dt = do
            u <- genDecisionTree tbody dt selections'
            liftA2 (,) (getLocal u) (use currentBlockLabel)
    v <- genDecisionTree' def
    let genCase l dt = do
            commitToNewBlock (br nextL) l
            genDecisionTree tbody dt selections'
    vs <- zipWithM ((getLocal <=<) . genCase) variantLs variantDts
            genDecisionTree' dt
    vs <- zipWithM genCase variantLs variantDts
    commitToNewBlock (br nextL) nextL
    fmap VLocal (emitAnon (phi (zip (v : vs) (defaultL : variantLs))))
    fmap VLocal (emitAnon (phi (v : vs)))

genDecisionLeaf :: (MonoAst.VarBindings, Expr) -> Selections Operand -> Gen Val
genDecisionLeaf (bs, e) selections =