mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 06:34:11 +00:00
Be slightly picky about which nodes to kill.
Constant/label nodes should never be killed because they can (in theory) never change. While constants /can/ change in the Quake VM, it's not worth worrying about as there would be much more important things to worry about (like 2+2 not giving 4). Due to the hoops one would have to jump through, it is assumed that a pointer or an offset from that pointer will never overwrite the pointer.
This commit is contained in:
parent
22d72f33d2
commit
87121b4cf1
1 changed files with 18 additions and 2 deletions
|
@ -388,9 +388,25 @@ static void
|
|||
dag_kill_nodes (dag_t *dag, dagnode_t *n)
|
||||
{
|
||||
int i;
|
||||
dagnode_t *node;
|
||||
|
||||
for (i = 0; i < dag->num_nodes; i++)
|
||||
dag->nodes[i]->killed = 1;
|
||||
for (i = 0; i < dag->num_nodes; i++) {
|
||||
node = dag->nodes[i];
|
||||
if (node == n->children[1]) {
|
||||
// assume the pointer does not point to itself. This should be
|
||||
// reasonable because without casting, only a void pointer can
|
||||
// point to itself (the required type is recursive).
|
||||
continue;
|
||||
}
|
||||
if (node->label->op && !op_is_identifier (node->label->op)) {
|
||||
// While constants in the Quake VM can be changed via a pointer,
|
||||
// doing so would cause much more fun than a simple
|
||||
// mis-optimization would, so consider them safe from pointer
|
||||
// operations.
|
||||
continue;
|
||||
}
|
||||
node->killed = 1;
|
||||
}
|
||||
n->killed = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue