add_goto() uses the active BB (and automaticallydesactive it just after). This is fine at linearization but is not what is needed at later stages. So, extract the gist into a separate helper: add_jump(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- linearize.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/linearize.c b/linearize.c index 4e9f9b3693e9..a2cde941ce18 100644 --- a/linearize.c +++ b/linearize.c @@ -633,16 +633,21 @@ static void finish_block(struct entrypoint *ep) ep->active = NULL; } +static void add_jump(struct basic_block *src, struct basic_block *dst) +{ + struct instruction *br = alloc_instruction(OP_BR, 0); + br->bb_true = dst; + add_bb(&dst->parents, src); + add_bb(&src->children, dst); + br->bb = src; + add_instruction(&src->insns, br); +} + static void add_goto(struct entrypoint *ep, struct basic_block *dst) { struct basic_block *src = ep->active; if (bb_reachable(src)) { - struct instruction *br = alloc_instruction(OP_BR, 0); - br->bb_true = dst; - add_bb(&dst->parents, src); - add_bb(&src->children, dst); - br->bb = src; - add_instruction(&src->insns, br); + add_jump(src, dst); ep->active = NULL; } } -- 2.26.0