ir_to_mesa: Don't emit a duplicate return at the end of a function.
authorEric Anholt <eric@anholt.net>
Thu, 29 Jul 2010 22:17:23 +0000 (15:17 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 29 Jul 2010 22:19:37 +0000 (15:19 -0700)
It was harmless, but ugly.

src/mesa/program/ir_to_mesa.cpp

index 3a28c566d4d2e078e53a0e9736f98b289015e510..b6dfde3783e68f115f8d292c75ebe0e5d4629ffc 100644 (file)
@@ -2350,8 +2350,12 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
 
            visit_exec_list(&entry->sig->body, &v);
 
-           entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_RET);
-           entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB);
+           ir_to_mesa_instruction *last;
+           last = (ir_to_mesa_instruction *)v.instructions.get_tail();
+           if (last->op != OPCODE_RET)
+              v.ir_to_mesa_emit_op0(NULL, OPCODE_RET);
+
+           v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB);
            progress = GL_TRUE;
         }
       }