summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2016-04-08 17:43:48 -0400
committerJason Ekstrand <[email protected]>2016-04-28 15:52:17 -0700
commitddc6639f8596d0d44d84e0b0fd3a5461c953c4b2 (patch)
treeb71ce79cf55f68ae4bad6395e30b504945346400
parent3afb3be6748509ab262ad4a22f5594219156e396 (diff)
nir/opt_dce: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/nir/nir_opt_dce.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/compiler/nir/nir_opt_dce.c b/src/compiler/nir/nir_opt_dce.c
index ee656ac2a67..d94f4be28e0 100644
--- a/src/compiler/nir/nir_opt_dce.c
+++ b/src/compiler/nir/nir_opt_dce.c
@@ -113,10 +113,8 @@ init_instr(nir_instr *instr, struct exec_list *worklist)
}
static bool
-init_block_cb(nir_block *block, void *_state)
+init_block(nir_block *block, struct exec_list *worklist)
{
- struct exec_list *worklist = (struct exec_list *) _state;
-
nir_foreach_instr(block, instr)
init_instr(instr, worklist);
@@ -131,27 +129,14 @@ init_block_cb(nir_block *block, void *_state)
}
static bool
-delete_block_cb(nir_block *block, void *_state)
-{
- bool *progress = (bool *) _state;
-
- nir_foreach_instr_safe(block, instr) {
- if (!instr->pass_flags) {
- nir_instr_remove(instr);
- *progress = true;
- }
- }
-
- return true;
-}
-
-static bool
nir_opt_dce_impl(nir_function_impl *impl)
{
struct exec_list *worklist = ralloc(NULL, struct exec_list);
exec_list_make_empty(worklist);
- nir_foreach_block_call(impl, init_block_cb, worklist);
+ nir_foreach_block(block, impl) {
+ init_block(block, worklist);
+ }
while (!exec_list_is_empty(worklist)) {
nir_instr *instr = worklist_pop(worklist);
@@ -161,7 +146,15 @@ nir_opt_dce_impl(nir_function_impl *impl)
ralloc_free(worklist);
bool progress = false;
- nir_foreach_block_call(impl, delete_block_cb, &progress);
+
+ nir_foreach_block(block, impl) {
+ nir_foreach_instr_safe(block, instr) {
+ if (!instr->pass_flags) {
+ nir_instr_remove(instr);
+ progress = true;
+ }
+ }
+ }
if (progress)
nir_metadata_preserve(impl, nir_metadata_block_index |