From f5e84ec44cc9301616c46367983edc945934e1ef Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 22 Mar 2023 23:58:08 +0300 Subject: [PATCH] Simplify compilation pipeline --- ir_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ir_main.c b/ir_main.c index 57f5e71..e8c097f 100644 --- a/ir_main.c +++ b/ir_main.c @@ -137,15 +137,15 @@ static int _save(ir_ctx *ctx, uint32_t dump, uint32_t pass, const char *dump_fil int ir_compile_func(ir_ctx *ctx, int opt_level, uint32_t dump, const char *dump_file) { - if (opt_level > 0) { - ir_build_def_use_lists(ctx); - } - if ((dump & (IR_DUMP_AFTER_LOAD|IR_DUMP_AFTER_ALL)) && !_save(ctx, dump, IR_DUMP_AFTER_LOAD, dump_file)) { return 0; } + if (opt_level > 0 || (ctx->flags & (IR_GEN_NATIVE|IR_GEN_C))) { + ir_build_def_use_lists(ctx); + } + ir_check(ctx); /* Global Optimization */ @@ -157,10 +157,14 @@ int ir_compile_func(ir_ctx *ctx, int opt_level, uint32_t dump, const char *dump_ } } + if (opt_level > 0 || (ctx->flags & (IR_GEN_NATIVE|IR_GEN_C))) { + ir_build_cfg(ctx); + } + /* Schedule */ if (opt_level > 0) { - ir_build_cfg(ctx); if (opt_level == 1) { + /* With -O2 unreachable blocks are removed by SCCP */ ir_remove_unreachable_blocks(ctx); } ir_build_dominators_tree(ctx); @@ -175,9 +179,6 @@ int ir_compile_func(ir_ctx *ctx, int opt_level, uint32_t dump, const char *dump_ && !_save(ctx, dump, IR_DUMP_AFTER_SCHEDULE, dump_file)) { return 0; } - } else if (ctx->flags & (IR_GEN_NATIVE|IR_GEN_C)) { - ir_build_def_use_lists(ctx); - ir_build_cfg(ctx); } if (ctx->flags & IR_GEN_NATIVE) {