diff options
author | Paul Berry <[email protected]> | 2011-07-01 12:14:07 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2011-07-08 09:59:30 -0700 |
commit | afc9a50fba39df520046019c6993d7b7559329ea (patch) | |
tree | d9c3523e5129568cffc8f03d004d71be9cdbdd30 /src/glsl/lower_jumps.cpp | |
parent | dbaa2e627effbe1361e1a69c23cf247cf86f2709 (diff) |
glsl: Lower unconditional return statements.
Previously, lower_jumps.cpp only lowered return statements that
appeared inside of an if statement.
Without this patch, lower_jumps.cpp might not lower certain return
statements, causing some back-ends to fail (as in bug #36669).
Fixes unit test test_lower_returns_1.
Diffstat (limited to 'src/glsl/lower_jumps.cpp')
-rw-r--r-- | src/glsl/lower_jumps.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index fa247c6c9b9..eceba09266e 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -851,6 +851,20 @@ lower_continue: */ visit_block(&ir->body); + /* If the body ended in an unconditional return of non-void, + * then we don't need to lower it because it's the one canonical + * return. + * + * If the body ended in a return of void, eliminate it because + * it is redundant. + */ + if (ir->return_type->is_void() && + get_jump_strength((ir_instruction *) ir->body.get_tail())) { + ir_jump *jump = (ir_jump *) ir->body.get_tail(); + assert (jump->ir_type == ir_type_return); + jump->remove(); + } + if(this->function.return_value) ir->body.push_tail(new(ir) ir_return(new (ir) ir_dereference_variable(this->function.return_value))); |