On Thu, 19 Jan 2012, Jakub Jelinek wrote:

> Hi!
> 
> It isn't clear why mudflap doesn't instrument DECL_ARTIFICIAL functions,
> if it couldn't avoid instrumenting just a subset of them.
> But there is certainly no reason why it shouldn't instrument normal clones
> of user functions (OpenMP, TM, ISRA, ...).  Fixed thusly,
> bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2012-01-19  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR libmudflap/40778
>       * tree-mudflap.c (mf_artificial): New function.
>       (execute_mudflap_function_ops, execute_mudflap_function_decls,
>       mx_register_decls, mudflap_enqueue_decl): Use it.
> 
>       * testsuite/libmudflap.c/fail68-frag.c: New test.
> 
> --- gcc/tree-mudflap.c        2011-12-08 16:36:52.233959103 +0100
> +++ gcc/tree-mudflap.c        2012-01-19 11:18:45.817151412 +0100
> @@ -69,6 +69,13 @@ static tree mx_xfn_xform_decls (gimple_s
>  static gimple_seq mx_register_decls (tree, gimple_seq, location_t);
>  static unsigned int execute_mudflap_function_decls (void);
>  
> +/* Return true if DECL is artificial stub that shouldn't be instrumented by
> +   mf.  We should instrument clones of non-artificial functions.  */
> +static inline bool
> +mf_artificial (const_tree decl)
> +{
> +  return DECL_ARTIFICIAL (DECL_ORIGIN (decl));
> +}
>  
>  /* ------------------------------------------------------------------------ 
> */
>  /* Some generally helpful functions for mudflap instrumentation.  */
> @@ -412,8 +419,8 @@ execute_mudflap_function_ops (void)
>  
>    /* Don't instrument functions such as the synthetic constructor
>       built during mudflap_finish_file.  */
> -  if (mf_marked_p (current_function_decl) ||
> -      DECL_ARTIFICIAL (current_function_decl))
> +  if (mf_marked_p (current_function_decl)
> +      || mf_artificial (current_function_decl))
>      return 0;
>  
>    push_gimplify_context (&gctx);
> @@ -994,8 +1001,8 @@ execute_mudflap_function_decls (void)
>  
>    /* Don't instrument functions such as the synthetic constructor
>       built during mudflap_finish_file.  */
> -  if (mf_marked_p (current_function_decl) ||
> -      DECL_ARTIFICIAL (current_function_decl))
> +  if (mf_marked_p (current_function_decl)
> +      || mf_artificial (current_function_decl))
>      return 0;
>  
>    push_gimplify_context (&gctx);
> @@ -1078,7 +1085,7 @@ mx_register_decls (tree decl, gimple_seq
>            /* Add the __mf_register call at the current appending point.  */
>            if (gsi_end_p (initially_stmts))
>           {
> -           if (!DECL_ARTIFICIAL (decl))
> +           if (!mf_artificial (decl))
>               warning (OPT_Wmudflap,
>                        "mudflap cannot track %qE in stub function",
>                        DECL_NAME (decl));
> @@ -1249,7 +1256,7 @@ mudflap_enqueue_decl (tree obj)
>       during mudflap_finish_file ().  That would confuse the user,
>       since the text would refer to variables that don't show up in the
>       user's source code.  */
> -  if (DECL_P (obj) && DECL_EXTERNAL (obj) && DECL_ARTIFICIAL (obj))
> +  if (DECL_P (obj) && DECL_EXTERNAL (obj) && mf_artificial (obj))
>      return;
>  
>    VEC_safe_push (tree, gc, deferred_static_decls, obj);
> --- libmudflap/testsuite/libmudflap.c/fail68-frag.c.jj        2010-12-16 
> 17:15:40.000000000 +0100
> +++ libmudflap/testsuite/libmudflap.c/fail68-frag.c   2010-12-16 
> 17:26:16.000000000 +0100
> @@ -0,0 +1,27 @@
> +/* PR libmudflap/40778 */
> +
> +char p[32];
> +static int j;
> +
> +__attribute__((noinline))
> +static void foo (int i)
> +{
> +  if (j++ == 0)
> +    p[i + 4] = 12;
> +  else
> +    p[i - 4] = 13;
> +}
> +
> +int
> +main ()
> +{
> +  foo (30);
> +  foo (30);
> +  foo (30);
> +  return 0;
> +}
> +
> +/* { dg-output "mudflap violation 1.*" } */
> +/* { dg-output "Nearby object 1.*" } */
> +/* { dg-output "mudflap object.*name.*p" } */
> +/* { dg-do run { xfail *-*-* } } */
> 
>       Jakub
> 
> 

-- 
Richard Guenther <rguent...@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer

Reply via email to