mirror of
https://github.com/danog/ir.git
synced 2024-11-26 20:34:53 +01:00
Allow SCCP to grow use_lists (through reallocation)
This commit is contained in:
parent
cdc34ae22b
commit
11db21a98c
2
ir.c
2
ir.c
@ -280,6 +280,7 @@ void ir_init(ir_ctx *ctx, ir_ref consts_limit, ir_ref insns_limit)
|
||||
|
||||
ctx->use_lists = NULL;
|
||||
ctx->use_edges = NULL;
|
||||
ctx->use_edges_count = 0;
|
||||
|
||||
ctx->cfg_blocks_count = 0;
|
||||
ctx->cfg_edges_count = 0;
|
||||
@ -939,6 +940,7 @@ void ir_build_def_use_lists(ir_ctx *ctx)
|
||||
}
|
||||
|
||||
ctx->use_edges = edges;
|
||||
ctx->use_edges_count = edges_count;
|
||||
ctx->use_lists = lists;
|
||||
}
|
||||
|
||||
|
1
ir.h
1
ir.h
@ -440,6 +440,7 @@ typedef struct _ir_ctx {
|
||||
ir_insn fold_insn;
|
||||
ir_use_list *use_lists; /* def->use lists for each instruction */
|
||||
ir_ref *use_edges;
|
||||
uint32_t use_edges_count;
|
||||
uint32_t cfg_blocks_count;
|
||||
uint32_t cfg_edges_count;
|
||||
ir_block *cfg_blocks; /* list of Basic Blocks (starts from 1) */
|
||||
|
1
ir_gcm.c
1
ir_gcm.c
@ -581,6 +581,7 @@ restart:
|
||||
}
|
||||
|
||||
new_ctx.use_edges = edges;
|
||||
new_ctx.use_edges_count = edges_count;
|
||||
new_ctx.use_lists = lists;
|
||||
|
||||
if (ctx->cfg_blocks) {
|
||||
|
10
ir_sccp.c
10
ir_sccp.c
@ -196,11 +196,17 @@ static void ir_sccp_add_to_use_list(ir_ctx *ctx, ir_ref to, ir_ref ref)
|
||||
ir_use_list *use_list = &ctx->use_lists[to];
|
||||
ir_ref n = use_list->refs + use_list->count;
|
||||
|
||||
if (ctx->use_edges[n] == IR_UNUSED) {
|
||||
if (n < ctx->use_edges_count && ctx->use_edges[n] == IR_UNUSED) {
|
||||
ctx->use_edges[n] = ref;
|
||||
use_list->count++;
|
||||
} else {
|
||||
IR_ASSERT(0 && "NIY: insert def->use edges"); // TODO:
|
||||
/* Reallocate the whole edges buffer (this is inefficient) */
|
||||
ctx->use_edges = ir_mem_realloc(ctx->use_edges, (ctx->use_edges_count + use_list->count + 1) * sizeof(ir_ref));
|
||||
memcpy(ctx->use_edges + ctx->use_edges_count, ctx->use_edges + use_list->refs, use_list->count * sizeof(ir_ref));
|
||||
use_list->refs = ctx->use_edges_count;
|
||||
ctx->use_edges[use_list->refs + use_list->count] = ref;
|
||||
use_list->count++;
|
||||
ctx->use_edges_count += use_list->count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user