From 6202cbfe3614141e330501959a7322522b35f4e4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Apr 2010 16:02:15 -0700 Subject: [PATCH] Fix ir_dead_code for function refactoring. --- ir.h | 6 ++++++ ir_dead_code.cpp | 19 ++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ir.h b/ir.h index fa9a1321e32..c93c043f5e5 100644 --- a/ir.h +++ b/ir.h @@ -52,6 +52,7 @@ public: */ /*@{*/ virtual class ir_variable * as_variable() { return NULL; } + virtual class ir_function * as_function() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } virtual class ir_label * as_label() { return NULL; } @@ -243,6 +244,11 @@ class ir_function : public ir_instruction { public: ir_function(const char *name); + virtual ir_function *as_function() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp index aae45d993ea..81fbeba3213 100644 --- a/ir_dead_code.cpp +++ b/ir_dead_code.cpp @@ -62,7 +62,6 @@ public: */ /*@{*/ virtual void visit(ir_variable *); - virtual void visit(ir_label *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); virtual void visit(ir_function_signature *); @@ -121,12 +120,6 @@ ir_dead_code_visitor::visit(ir_variable *ir) } -void -ir_dead_code_visitor::visit(ir_label *ir) -{ - ir->signature->accept(this); -} - void ir_dead_code_visitor::visit(ir_loop *ir) { @@ -325,10 +318,14 @@ do_dead_code_unlinked(exec_list *instructions) foreach_iter(exec_list_iterator, iter, *instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); - ir_label *label = ir->as_label(); - if (label) { - if (do_dead_code(&label->signature->body)) - progress = true; + ir_function *f = ir->as_function(); + if (f) { + foreach_iter(exec_list_iterator, sigiter, *f) { + ir_function_signature *sig = + (ir_function_signature *) sigiter.get(); + if (do_dead_code(&sig->body)) + progress = true; + } } } -- 2.30.2