diff mbox

Remove current_function_decl usage from get_polymorphic_call_info

Message ID 20140813141742.GB29331@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Aug. 13, 2014, 2:17 p.m. UTC
Hi,

Testing 'mpx' branch after merge with trunk I got a segfault in ipa-devirt.c.  It appears that cgraph_node cloning with indirect edge causes call to get_polymorphic_call_info which uses current_function_decl.  It happens in IPA pass and therefore current_function_decl is NULL which causes segfault.  Also even within a GIMPLE pass it seems wrong to use current_function_decl because examined call may belong to another function and passed fndecl should be used instead.

Proposed patch was bootstrapped and regtested on linux-x86_64.  OK for trunk?

Thanks,
Ilya
--

2014-08-13  Ilya Enkovich  <ilya.enkovich@intel.com>

	* ipa-devirt.c (get_polymorphic_call_info): Use fndecl instead of
	current_function_decl.

Comments

Richard Biener Aug. 13, 2014, 2:20 p.m. UTC | #1
On Wed, Aug 13, 2014 at 4:17 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> Testing 'mpx' branch after merge with trunk I got a segfault in ipa-devirt.c.  It appears that cgraph_node cloning with indirect edge causes call to get_polymorphic_call_info which uses current_function_decl.  It happens in IPA pass and therefore current_function_decl is NULL which causes segfault.  Also even within a GIMPLE pass it seems wrong to use current_function_decl because examined call may belong to another function and passed fndecl should be used instead.
>
> Proposed patch was bootstrapped and regtested on linux-x86_64.  OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Ilya
> --
>
> 2014-08-13  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         * ipa-devirt.c (get_polymorphic_call_info): Use fndecl instead of
>         current_function_decl.
>
>
> diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
> index 3650b43..0f38655 100644
> --- a/gcc/ipa-devirt.c
> +++ b/gcc/ipa-devirt.c
> @@ -2319,7 +2319,7 @@ get_polymorphic_call_info (tree fndecl,
>                      = decl_maybe_in_construction_p (base,
>                                                      context->outer_type,
>                                                      call,
> -                                                    current_function_decl);
> +                                                    fndecl);
>                   return base;
>                 }
>               else
Jan Hubicka Aug. 15, 2014, 9:06 p.m. UTC | #2
> Hi,
> 
> Testing 'mpx' branch after merge with trunk I got a segfault in ipa-devirt.c.  It appears that cgraph_node cloning with indirect edge causes call to get_polymorphic_call_info which uses current_function_decl.  It happens in IPA pass and therefore current_function_decl is NULL which causes segfault.  Also even within a GIMPLE pass it seems wrong to use current_function_decl because examined call may belong to another function and passed fndecl should be used instead.
> 
> Proposed patch was bootstrapped and regtested on linux-x86_64.  OK for trunk?

OK,
thanks

Honza
> 
> Thanks,
> Ilya
> --
> 
> 2014-08-13  Ilya Enkovich  <ilya.enkovich@intel.com>
> 
> 	* ipa-devirt.c (get_polymorphic_call_info): Use fndecl instead of
> 	current_function_decl.
> 
> 
> diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
> index 3650b43..0f38655 100644
> --- a/gcc/ipa-devirt.c
> +++ b/gcc/ipa-devirt.c
> @@ -2319,7 +2319,7 @@ get_polymorphic_call_info (tree fndecl,
>  		     = decl_maybe_in_construction_p (base,
>  						     context->outer_type,
>  						     call,
> -						     current_function_decl);
> +						     fndecl);
>  		  return base;
>  		}
>  	      else
diff mbox

Patch

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 3650b43..0f38655 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -2319,7 +2319,7 @@  get_polymorphic_call_info (tree fndecl,
 		     = decl_maybe_in_construction_p (base,
 						     context->outer_type,
 						     call,
-						     current_function_decl);
+						     fndecl);
 		  return base;
 		}
 	      else