reenabled control flow analysis pass

This commit is contained in:
Anthony Pesch 2017-08-17 20:23:21 -04:00
parent 357a210c79
commit f91c4f9d3b
5 changed files with 23 additions and 4 deletions

View File

@ -239,7 +239,7 @@ set(RELIB_SOURCES
src/jit/ir/ir_write.c
src/jit/passes/constant_propagation_pass.c
src/jit/passes/control_flow_analysis_pass.c
src/jit/passes/conversion_elimination_pass.c
#src/jit/passes/conversion_elimination_pass.c
src/jit/passes/dead_code_elimination_pass.c
src/jit/passes/expression_simplification_pass.c
src/jit/passes/load_store_elimination_pass.c

View File

@ -134,8 +134,6 @@ void ir_remove_block(struct ir *ir, struct ir_block *block) {
}
void ir_add_edge(struct ir *ir, struct ir_block *src, struct ir_block *dst) {
CHECK_NE(src, dst);
/* linked list data is intrusive, need to allocate two edge objects */
{
struct ir_edge *edge = ir_calloc(ir, sizeof(struct ir_edge));

View File

@ -193,6 +193,20 @@ static void ir_write_instr(struct ir_writer *w, const struct ir_instr *instr,
static void ir_write_block(struct ir_writer *w, const struct ir_block *block,
FILE *output) {
/* write out control flow information */
fprintf(output, "# predecessors ");
list_for_each_entry(edge, &block->incoming, struct ir_edge, it) {
fprintf(output, "%%%d ", ir_get_block_label(w, edge->src));
}
fprintf(output, "\n");
fprintf(output, "# successors ");
list_for_each_entry(edge, &block->outgoing, struct ir_edge, it) {
fprintf(output, "%%%d ", ir_get_block_label(w, edge->dst));
}
fprintf(output, "\n");
/* write out actual block */
fprintf(output, "%%%d:", ir_get_block_label(w, block));
ir_write_meta(w, block, output);
fprintf(output, "\n");

View File

@ -9,6 +9,7 @@
#include "jit/jit_backend.h"
#include "jit/jit_frontend.h"
#include "jit/passes/constant_propagation_pass.h"
#include "jit/passes/control_flow_analysis_pass.h"
#include "jit/passes/dead_code_elimination_pass.h"
#include "jit/passes/expression_simplification_pass.h"
#include "jit/passes/load_store_elimination_pass.h"
@ -373,6 +374,7 @@ void jit_compile_code(struct jit *jit, uint32_t guest_addr) {
/* run optimization passes */
jit_promote_fastmem(jit, block, &ir);
cfa_run(jit->cfa, &ir);
lse_run(jit->lse, &ir);
cprop_run(jit->cprop, &ir);
esimp_run(jit->esimp, &ir);
@ -477,6 +479,10 @@ void jit_destroy(struct jit *jit) {
lse_destroy(jit->lse);
}
if (jit->cfa) {
cfa_destroy(jit->cfa);
}
if (jit->exc_handler) {
exception_handler_remove(jit->exc_handler);
}
@ -493,6 +499,7 @@ struct jit *jit_create(const char *tag, struct jit_frontend *frontend,
jit->backend = backend;
/* create optimization passes */
jit->cfa = cfa_create();
jit->lse = lse_create();
jit->cprop = cprop_create();
jit->esimp = esimp_create();

View File

@ -8,7 +8,7 @@ void cfa_run(struct cfa *cfa, struct ir *ir) {
/* add edges between blocks for easy traversing */
if (instr->op == OP_BRANCH || instr->op == OP_BRANCH_FALSE ||
instr->op == OP_BRANCH_TRUE) {
if (instr->arg[0]->blk) {
if (instr->arg[0]->type == VALUE_BLOCK) {
ir_add_edge(ir, block, instr->arg[0]->blk);
}
}