mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-06 09:21:01 +00:00
[qfcc] Unalias def ops too
When I implemented the st_alias handing (d8a78fc849
) I was
unsure if I needed to unalias aliased defs too, but it turns out to have
been necessary: this is what caused my 2d PGA dynamics test to blow up
strangely due to the GA vector loaded from an array into a local
variable getting the local var replaced by a temp but the var itself
being read later in the code (uninitialized variable due to incorrect
optimization... oops).
This commit is contained in:
parent
37fe0bc4ed
commit
3d26aafbea
2 changed files with 30 additions and 10 deletions
|
@ -107,11 +107,14 @@ op_is_temp (operand_t *op)
|
|||
return op->op_type == op_temp;
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
op_is_alias (operand_t *op)
|
||||
{
|
||||
if (!op) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
if (op->op_type == op_alias) {
|
||||
return true;
|
||||
}
|
||||
if (op->op_type == op_temp) {
|
||||
return !!op->tempop.alias;
|
||||
|
@ -119,7 +122,7 @@ op_is_alias (operand_t *op)
|
|||
if (op->op_type == op_def) {
|
||||
return !!op->def->alias;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int __attribute__((pure))
|
||||
|
@ -131,6 +134,9 @@ op_alias_offset (operand_t *op)
|
|||
if (op->op_type == op_temp) {
|
||||
return op->tempop.offset;
|
||||
}
|
||||
if (op->op_type == op_def) {
|
||||
return op->def->offset;
|
||||
}
|
||||
internal_error (op->expr, "eh? how?");
|
||||
}
|
||||
|
||||
|
@ -140,12 +146,15 @@ unalias_op (operand_t *op)
|
|||
if (!op_is_alias (op)) {
|
||||
internal_error (op->expr, "not an alias op");
|
||||
}
|
||||
if (op->op_type == op_alias) {
|
||||
return op->alias;;
|
||||
}
|
||||
if (op->op_type == op_temp) {
|
||||
return op->tempop.alias;
|
||||
}
|
||||
if (op->op_type == op_def) {
|
||||
// XXX FIXME needed?
|
||||
return op;
|
||||
auto def = op->def;
|
||||
return def_operand (def->alias, def->alias->type, op->expr);
|
||||
}
|
||||
internal_error (op->expr, "eh? how?");
|
||||
}
|
||||
|
@ -1340,9 +1349,12 @@ dag_gencode (dag_t *dag, sblock_t *block, dagnode_t *dagnode)
|
|||
|| dagnode->children[1] || dagnode->children[2]) {
|
||||
internal_error (dagnode->label->expr, "invalid alias node");
|
||||
}
|
||||
auto value = dagnode->children[0]->value;
|
||||
if (op_is_alias (value)) {
|
||||
value = unalias_op (value);
|
||||
}
|
||||
dst = offset_alias_operand (dagnode->types[0], dagnode->offset,
|
||||
dagnode->children[0]->value,
|
||||
dagnode->label->expr);
|
||||
value, dagnode->label->expr);
|
||||
if ((var_iter = set_first (dagnode->identifiers))) {
|
||||
type = dst->type;
|
||||
dst = generate_assignments (dag, block, dst, var_iter, type);
|
||||
|
|
|
@ -78,8 +78,11 @@ print_root_nodes (dstring_t *dstr, dag_t *dag)
|
|||
for (node_iter = set_first (dag->roots); node_iter;
|
||||
node_iter = set_next (node_iter)) {
|
||||
dagnode_t *node = dag->nodes[node_iter->element];
|
||||
//if (set_is_empty (node->edges)) {
|
||||
// continue;
|
||||
//}
|
||||
print_node_def (dstr, dag, node);
|
||||
dasprintf (dstr, " dag_enter_%p ->dagnode_%p [style=invis];\n",
|
||||
dasprintf (dstr, " dag_enter_%p -> dagnode_%p [style=invis];\n",
|
||||
dag, node);
|
||||
}
|
||||
// dasprintf (dstr, " }\n");
|
||||
|
@ -173,8 +176,13 @@ print_dag (dstring_t *dstr, dag_t *dag, const char *label)
|
|||
dasprintf (dstr, " dag_enter_%p [label=\"\", style=invis];\n", dag);
|
||||
print_root_nodes (dstr, dag);
|
||||
print_child_nodes (dstr, dag);
|
||||
for (i = 0; i < dag->num_nodes; i++)
|
||||
print_node (dstr, dag, dag->nodes[i]);
|
||||
for (i = 0; i < dag->num_nodes; i++) {
|
||||
auto node = dag->nodes[i];
|
||||
//if (set_is_empty (node->parents) && set_is_empty (node->edges)) {
|
||||
// continue;
|
||||
//}
|
||||
print_node (dstr, dag, node);
|
||||
}
|
||||
dasprintf (dstr, " dag_leave_%p [label=\"\", style=invis];\n", dag);
|
||||
if (label)
|
||||
dasprintf (dstr, " }\n");
|
||||
|
|
Loading…
Reference in a new issue