radeon / r200: Pass the API into _mesa_initialize_context
[mesa.git] / src / glsl / opt_dead_functions.cpp
index 7c64c618c0ca4b683bccb0d21063de55547462ee..8bb278e4537d06158aba42121b2c37d5cc5127e5 100644 (file)
@@ -32,6 +32,8 @@
 #include "ir_expression_flattening.h"
 #include "glsl_types.h"
 
+namespace {
+
 class signature_entry : public exec_node
 {
 public:
@@ -50,7 +52,6 @@ public:
    ir_dead_functions_visitor()
    {
       this->mem_ctx = ralloc_context(NULL);
-      this->seen_another_function_signature = false;
    }
 
    ~ir_dead_functions_visitor()
@@ -63,21 +64,18 @@ public:
 
    signature_entry *get_signature_entry(ir_function_signature *var);
 
-   bool (*predicate)(ir_instruction *ir);
-
-   bool seen_another_function_signature;
-
    /* List of signature_entry */
    exec_list signature_list;
    void *mem_ctx;
 };
 
+} /* unnamed namespace */
 
 signature_entry *
 ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig)
 {
-   foreach_iter(exec_list_iterator, iter, this->signature_list) {
-      signature_entry *entry = (signature_entry *)iter.get();
+   foreach_list(n, &this->signature_list) {
+      signature_entry *entry = (signature_entry *) n;
       if (entry->signature == sig)
         return entry;
    }
@@ -97,13 +95,7 @@ ir_dead_functions_visitor::visit_enter(ir_function_signature *ir)
       entry->used = true;
    }
 
-   /* If this is the first signature to look at, no need to descend to see
-    * if it has calls to another function signature.
-    */
-   if (!this->seen_another_function_signature) {
-      this->seen_another_function_signature = true;
-      return visit_continue_with_parent;
-   }
+
 
    return visit_continue;
 }
@@ -112,7 +104,7 @@ ir_dead_functions_visitor::visit_enter(ir_function_signature *ir)
 ir_visitor_status
 ir_dead_functions_visitor::visit_enter(ir_call *ir)
 {
-   signature_entry *entry = this->get_signature_entry(ir->get_callee());
+   signature_entry *entry = this->get_signature_entry(ir->callee);
 
    entry->used = true;
 
@@ -131,8 +123,8 @@ do_dead_functions(exec_list *instructions)
     * the unused ones, and remove function definitions that have no more
     * signatures.
     */
-    foreach_iter(exec_list_iterator, iter, v.signature_list) {
-      signature_entry *entry = (signature_entry *)iter.get();
+    foreach_list_safe(n, &v.signature_list) {
+      signature_entry *entry = (signature_entry *) n;
 
       if (!entry->used) {
         entry->signature->remove();
@@ -145,8 +137,8 @@ do_dead_functions(exec_list *instructions)
    /* We don't just do this above when we nuked a signature because of
     * const pointers.
     */
-   foreach_iter(exec_list_iterator, iter, *instructions) {
-      ir_instruction *ir = (ir_instruction *)iter.get();
+   foreach_list_safe(n, instructions) {
+      ir_instruction *ir = (ir_instruction *) n;
       ir_function *func = ir->as_function();
 
       if (func && func->signatures.is_empty()) {