Skip to content

Commit

Permalink
fix weird bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-s168 committed Oct 22, 2024
1 parent 4197a82 commit b60f2f0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions cg/x86_stupid/cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,7 @@ void vx_cg_x86stupid_gen(vx_IrBlock* block, FILE* out) {
for (size_t i = 0; i < op->args_len; i ++) {
vx_IrValue val = op->args[i];
if (val.type == VX_IR_VAL_VAR) {
assert(varData);
varData[val.var].heat ++;
}
}
Expand Down
12 changes: 5 additions & 7 deletions ir/analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,18 +449,16 @@ static bool var_used_val(vx_IrValue val, vx_IrVar var) {
}

bool vx_IrOp_varUsed(const vx_IrOp *op, vx_IrVar var) {
for (size_t j = 0; j < op->params_len; j++) {
if (var_used_val(op->params[j].val, var)) return true;
}
for (size_t i = 0; i < op->args_len; i ++) {
if (var_used_val(op->args[i], var)) return true;
}
FOR_INPUTS(op, inp, ({
if (var_used_val(inp, var))
return true;
}));
return false;
}

bool vx_IrBlock_varUsed(vx_IrBlock *block, vx_IrVar var)
{
if (block == NULL) return false;
assert(block);

for (size_t i = 0; i < block->outs_len; i++)
if (block->outs[i] == var)
Expand Down
4 changes: 2 additions & 2 deletions ir/opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ static void RecCallInOut(void (*fn)(vx_IrBlock*), vx_IrBlock* block)

static void opt_pre(vx_IrBlock *block) {
// place immediates into params
vx_opt_inline_vars(block);
// vx_opt_inline_vars(block);

vx_opt_vars(block);

for (size_t i = 0; i < vx_g_optconfig.consteval_iterations; i ++) {
// evaluate constants
vx_opt_constant_eval(block);
// place results into params
vx_opt_inline_vars(block);
// vx_opt_inline_vars(block);
}

vx_opt_simple_patterns(block);
Expand Down
2 changes: 2 additions & 0 deletions ir/opt/inline_vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ struct vx_IrView_substitute_var__data {
vx_IrOp* newSrc;
};

// TODO: fix this piece of shit (probably broken because both ops in diff blocks)

static bool vx_IrView_substitute_var__trav(vx_IrOp *op, void *dataIn) {
struct vx_IrView_substitute_var__data *data = dataIn;

Expand Down
1 change: 1 addition & 0 deletions ir/opt/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ static bool canForceRem(vx_IrOp* op)
void vx_opt_vars(vx_IrBlock *block) {
vx_IrBlock *root = vx_IrBlock_root(block);
assert(root != NULL);
assert(root->is_root);

for (vx_IrOp *op = block->first; op; op = op->next) {
if (vx_IrOp_isVolatile(op) || vx_IrOp_hasSideEffect(op))
Expand Down

0 comments on commit b60f2f0

Please sign in to comment.