mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-18 15:58:06 +02:00
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.
(cherry picked from commit afc9a50fba)
This commit is contained in:
parent
2ba0d0a5e8
commit
934c7a0661
1 changed files with 14 additions and 0 deletions
|
|
@ -538,6 +538,20 @@ lower_continue:
|
|||
assert(!this->loop.loop);
|
||||
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)));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue