glsl2: Empty functions can be inlined.
authorTilman Sauerbeck <tilman@code-monkey.de>
Fri, 17 Sep 2010 16:50:07 +0000 (18:50 +0200)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 17 Sep 2010 23:28:47 +0000 (01:28 +0200)
Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ir_function_can_inline.cpp

index 8bb8e0d9ed70f185b371ff4516f8f851419c8e69..f29f277ef4b50683848e08d8c3960e5ba7f43860 100644 (file)
@@ -63,8 +63,11 @@ can_inline(ir_call *call)
 
    v.run((exec_list *) &callee->body);
 
+   /* If the function is empty (no last instruction) or does not end with a
+    * return statement, we need to count the implicit return.
+    */
    ir_instruction *last = (ir_instruction *)callee->body.get_tail();
-   if (last && !last->as_return())
+   if (last == NULL || !last->as_return())
       v.num_returns++;
 
    return v.num_returns == 1;