egl: Fix an assertion in _eglUpdateAPIsString.
[mesa.git] / src / glsl / ir_function_can_inline.cpp
index 8bb8e0d9ed70f185b371ff4516f8f851419c8e69..c367c30e44f37a7453481784d1f96b370ea2047a 100644 (file)
@@ -60,11 +60,16 @@ can_inline(ir_call *call)
 {
    ir_function_can_inline_visitor v;
    const ir_function_signature *callee = call->get_callee();
+   if (!callee->is_defined)
+      return false;
 
    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;