diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/ir_variable_refcount.cpp | 21 | ||||
-rw-r--r-- | src/glsl/ir_variable_refcount.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/glsl/ir_variable_refcount.cpp b/src/glsl/ir_variable_refcount.cpp index 923eb1a8274..425ed812dc3 100644 --- a/src/glsl/ir_variable_refcount.cpp +++ b/src/glsl/ir_variable_refcount.cpp @@ -132,3 +132,24 @@ ir_variable_refcount_visitor::visit_leave(ir_assignment *ir) return visit_continue; } + + +ir_visitor_status +ir_variable_refcount_visitor::visit_leave(ir_loop *ir) +{ + /* If the loop has a counter variable, it is implicitly referenced and + * assigned to. Note that since the LHS of an assignment is counted as a + * reference, we actually have to increment referenced_count by 2 so that + * later code will know that the variable isn't just assigned to. + */ + if (ir->counter != NULL) { + ir_variable_refcount_entry *entry = + this->get_variable_entry(ir->counter); + if (entry) { + entry->referenced_count += 2; + entry->assigned_count++; + } + } + + return visit_continue; +} diff --git a/src/glsl/ir_variable_refcount.h b/src/glsl/ir_variable_refcount.h index c15e8110d04..03fa7b5b467 100644 --- a/src/glsl/ir_variable_refcount.h +++ b/src/glsl/ir_variable_refcount.h @@ -60,6 +60,7 @@ public: virtual ir_visitor_status visit_enter(ir_function_signature *); virtual ir_visitor_status visit_leave(ir_assignment *); + virtual ir_visitor_status visit_leave(ir_loop *); ir_variable_refcount_entry *get_variable_entry(ir_variable *var); |