Skip to content

Commit 8e9ab17

Browse files
committed
Deduplicate dominates() function
1 parent 5cc656b commit 8e9ab17

File tree

5 files changed

+3
-23
lines changed

5 files changed

+3
-23
lines changed

Zend/Optimizer/dfa_pass.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,14 +1066,6 @@ static bool zend_dfa_try_to_replace_result(zend_op_array *op_array, zend_ssa *ss
10661066
return 0;
10671067
}
10681068

1069-
// FIXME: copied from zend_ssa.c (which is a copy from zend_cfg.c)
1070-
static bool dominates(const zend_basic_block *blocks, int a, int b) {
1071-
while (blocks[b].level > blocks[a].level) {
1072-
b = blocks[b].idom;
1073-
}
1074-
return a == b;
1075-
}
1076-
10771069
static bool op_dominates(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *a, const zend_op *b)
10781070
{
10791071
uint32_t a_block = ssa->cfg.map[a - op_array->opcodes];

Zend/Optimizer/zend_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ ZEND_API void zend_cfg_compute_dominators_tree(const zend_op_array *op_array, ze
761761
}
762762
/* }}} */
763763

764-
static bool dominates(zend_basic_block *blocks, int a, int b) /* {{{ */
764+
bool dominates(const zend_basic_block *blocks, int a, int b) /* {{{ */
765765
{
766766
while (blocks[b].level > blocks[a].level) {
767767
b = blocks[b].idom;

Zend/Optimizer/zend_cfg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ void zend_cfg_remark_reachable_blocks(const zend_op_array *op_array, zend_cfg *c
120120
ZEND_API void zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg);
121121
ZEND_API void zend_cfg_compute_dominators_tree(const zend_op_array *op_array, zend_cfg *cfg);
122122
ZEND_API void zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg);
123+
bool dominates(const zend_basic_block *blocks, int a, int b);
123124

124125
END_EXTERN_C()
125126

Zend/Optimizer/zend_ssa.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@
1818
*/
1919

2020
#include "zend_compile.h"
21+
#include "zend_cfg.h"
2122
#include "zend_dfg.h"
2223
#include "zend_ssa.h"
2324
#include "zend_dump.h"
2425
#include "zend_inference.h"
2526
#include "Optimizer/zend_optimizer_internal.h"
2627

27-
static bool dominates(const zend_basic_block *blocks, int a, int b) {
28-
while (blocks[b].level > blocks[a].level) {
29-
b = blocks[b].idom;
30-
}
31-
return a == b;
32-
}
33-
3428
static bool will_rejoin(
3529
const zend_cfg *cfg, const zend_dfg *dfg, const zend_basic_block *block,
3630
int other_successor, int exclude, int var) {

ext/opcache/jit/zend_jit.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,6 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
156156
zend_jit_addr res_addr,
157157
bool check_exception);
158158

159-
static bool dominates(const zend_basic_block *blocks, int a, int b) {
160-
while (blocks[b].level > blocks[a].level) {
161-
b = blocks[b].idom;
162-
}
163-
return a == b;
164-
}
165-
166159
static bool zend_ssa_is_last_use(const zend_op_array *op_array, const zend_ssa *ssa, int var, int use)
167160
{
168161
int next_use;

0 commit comments

Comments
 (0)