On Wed, Feb 06, 2013 at 02:45:10PM +0100, Michael Matz wrote:
> @@ -1329,20 +1337,53 @@ add_or_mark_expr (basic_block bb, tree e
>      }
>  }
>  
> +/* Return true when CALL is a call stmt that definitely doesn't
> +   free any memory or makes it unavailable otherwise.  */
> +static bool
> +nonfreeing_call_p (gimple call)
> +{
> +  tree fndecl = gimple_call_fndecl (call);
> +
> +  if (!fndecl || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
> +    return false;
> +
> +  switch (DECL_FUNCTION_CODE (fndecl))
> +    {
> +      case BUILT_IN_FREE:
> +      case BUILT_IN_STACK_RESTORE:
> +     return false;
> +      default:
> +     return true;
> +    }
> +}

This doesn't look conservative enough.

First of all, I'd use gimple_call_builtin_p (call, BUILT_IN_NORMAL)
test.  And, the function should certainly conservatively return false
for all builtins that aren't (gimple_call_flags (call) & ECF_LEAF) != 0,
otherwise they might call hooks in the current CU and similar and free in
those hooks (likewise setjmp or similar, but again, that is not ECF_LEAF).

        Jakub

Reply via email to