diff mbox

[CHKP] Never expand instrumentation thunks

Message ID 20150318121912.GB64546@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich March 18, 2015, 12:19 p.m. UTC
Hi,

This patch disables attempts to expand instrumentation thunks which appear when we create specialized function versions.  Problem was found during SPEC2006 insatrumentation with '-Ofast -flto'.  Unfortunately I couldn't make a small reproducer.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>

	* cgraphunit.c (cgraph_node::expand_thunk): Don't expand
	instrumentation thunks.

Comments

Ilya Enkovich April 2, 2015, 2:51 p.m. UTC | #1
Ping. Patch doesn't affect not instrumented code.

Thanks,
Ilya

2015-03-18 15:19 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> Hi,
>
> This patch disables attempts to expand instrumentation thunks which appear when we create specialized function versions.  Problem was found during SPEC2006 insatrumentation with '-Ofast -flto'.  Unfortunately I couldn't make a small reproducer.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>
> Thanks,
> Ilya
> --
> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>
>         * cgraphunit.c (cgraph_node::expand_thunk): Don't expand
>         instrumentation thunks.
>
>
> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index e640907..abc9cfe 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -1508,6 +1508,10 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
>    tree thunk_fndecl = decl;
>    tree a;
>
> +  /* Instrumentation thunk is the same function with
> +     a different signature.  Never need to expand it.  */
> +  if (thunk.add_pointer_bounds_args)
> +    return false;
>
>    if (!force_gimple_thunk && this_adjusting
>        && targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset,
Jeff Law April 2, 2015, 7:51 p.m. UTC | #2
On 04/02/2015 08:51 AM, Ilya Enkovich wrote:
> Ping. Patch doesn't affect not instrumented code.
>
> Thanks,
> Ilya
>
> 2015-03-18 15:19 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
>> Hi,
>>
>> This patch disables attempts to expand instrumentation thunks which appear when we create specialized function versions.  Problem was found during SPEC2006 insatrumentation with '-Ofast -flto'.  Unfortunately I couldn't make a small reproducer.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>>
>> Thanks,
>> Ilya
>> --
>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>
>>          * cgraphunit.c (cgraph_node::expand_thunk): Don't expand
>>          instrumentation thunks.
So is it the case that these instrumentation thunks have a gimple body 
and thus will be expanded elsewhere?  Or are you trying to solve some 
different problem?

Jeff
Jan Hubicka April 2, 2015, 8:11 p.m. UTC | #3
> > 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
> >
> >         * cgraphunit.c (cgraph_node::expand_thunk): Don't expand
> >         instrumentation thunks.
> >
> >
> > diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> > index e640907..abc9cfe 100644
> > --- a/gcc/cgraphunit.c
> > +++ b/gcc/cgraphunit.c
> > @@ -1508,6 +1508,10 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
> >    tree thunk_fndecl = decl;
> >    tree a;
> >
> > +  /* Instrumentation thunk is the same function with
> > +     a different signature.  Never need to expand it.  */
> > +  if (thunk.add_pointer_bounds_args)
> > +    return false;

Yeah, this is another case where we hit problem with transparent alias pretending
to be thunk :)
I guess the patch is OK for GCC-5 and for next stage1 we can clean this up.

Honza
> >
> >    if (!force_gimple_thunk && this_adjusting
> >        && targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset,
Jeff Law April 2, 2015, 8:26 p.m. UTC | #4
On 04/02/2015 02:11 PM, Jan Hubicka wrote:
>>> 2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>>>
>>>          * cgraphunit.c (cgraph_node::expand_thunk): Don't expand
>>>          instrumentation thunks.
>>>
>>>
>>> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
>>> index e640907..abc9cfe 100644
>>> --- a/gcc/cgraphunit.c
>>> +++ b/gcc/cgraphunit.c
>>> @@ -1508,6 +1508,10 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
>>>     tree thunk_fndecl = decl;
>>>     tree a;
>>>
>>> +  /* Instrumentation thunk is the same function with
>>> +     a different signature.  Never need to expand it.  */
>>> +  if (thunk.add_pointer_bounds_args)
>>> +    return false;
>
> Yeah, this is another case where we hit problem with transparent alias pretending
> to be thunk :)
> I guess the patch is OK for GCC-5 and for next stage1 we can clean this up.
I was actually building a compiler so I could take a look at this one 
under a debugger ;-)

jeff
Jan Hubicka April 2, 2015, 9:13 p.m. UTC | #5
> On 04/02/2015 02:11 PM, Jan Hubicka wrote:
> >>>2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
> >>>
> >>>         * cgraphunit.c (cgraph_node::expand_thunk): Don't expand
> >>>         instrumentation thunks.
> >>>
> >>>
> >>>diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> >>>index e640907..abc9cfe 100644
> >>>--- a/gcc/cgraphunit.c
> >>>+++ b/gcc/cgraphunit.c
> >>>@@ -1508,6 +1508,10 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
> >>>    tree thunk_fndecl = decl;
> >>>    tree a;
> >>>
> >>>+  /* Instrumentation thunk is the same function with
> >>>+     a different signature.  Never need to expand it.  */
> >>>+  if (thunk.add_pointer_bounds_args)
> >>>+    return false;
> >
> >Yeah, this is another case where we hit problem with transparent alias pretending
> >to be thunk :)
> >I guess the patch is OK for GCC-5 and for next stage1 we can clean this up.
> I was actually building a compiler so I could take a look at this
> one under a debugger ;-)

I think it is really the transparent alias issue.  The comment seems pretty clear about it.
What is confusing is that instrumentation thunks are called thunks when they are
really not - thunk is a small hunk of code, while instrumentation thunk is a transparent
alias.

Too bad I did not notice we introduced transparent aliases, i would push out my
code for that. I will compare Ilya's changes with mine and hopefully we can
catch more bugs and unify the code next stage1.

Honza
Jeff Law April 2, 2015, 9:16 p.m. UTC | #6
On 04/02/2015 03:13 PM, Jan Hubicka wrote:
>
> I think it is really the transparent alias issue.  The comment seems pretty clear about it.
> What is confusing is that instrumentation thunks are called thunks when they are
> really not - thunk is a small hunk of code, while instrumentation thunk is a transparent
> alias.
And it may be the terminology gets in the way.  I was at least partly 
interested in what code we generated for that testcase.

>
> Too bad I did not notice we introduced transparent aliases, i would push out my
> code for that. I will compare Ilya's changes with mine and hopefully we can
> catch more bugs and unify the code next stage1.
Sounds good.
jeff
Ilya Enkovich April 3, 2015, 8:57 a.m. UTC | #7
2015-04-03 0:13 GMT+03:00 Jan Hubicka <hubicka@ucw.cz>:
>> On 04/02/2015 02:11 PM, Jan Hubicka wrote:
>> >>>2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
>> >>>
>> >>>         * cgraphunit.c (cgraph_node::expand_thunk): Don't expand
>> >>>         instrumentation thunks.
>> >>>
>> >>>
>> >>>diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
>> >>>index e640907..abc9cfe 100644
>> >>>--- a/gcc/cgraphunit.c
>> >>>+++ b/gcc/cgraphunit.c
>> >>>@@ -1508,6 +1508,10 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
>> >>>    tree thunk_fndecl = decl;
>> >>>    tree a;
>> >>>
>> >>>+  /* Instrumentation thunk is the same function with
>> >>>+     a different signature.  Never need to expand it.  */
>> >>>+  if (thunk.add_pointer_bounds_args)
>> >>>+    return false;
>> >
>> >Yeah, this is another case where we hit problem with transparent alias pretending
>> >to be thunk :)
>> >I guess the patch is OK for GCC-5 and for next stage1 we can clean this up.
>> I was actually building a compiler so I could take a look at this
>> one under a debugger ;-)
>
> I think it is really the transparent alias issue.  The comment seems pretty clear about it.
> What is confusing is that instrumentation thunks are called thunks when they are
> really not - thunk is a small hunk of code, while instrumentation thunk is a transparent
> alias.
>
> Too bad I did not notice we introduced transparent aliases, i would push out my
> code for that. I will compare Ilya's changes with mine and hopefully we can
> catch more bugs and unify the code next stage1.

Thunk was the best I could find to represent the same function but
with different signature. It would be great to have a more specialized
way for that.

Thanks,
Ilya

>
> Honza
Jan Hubicka April 3, 2015, 5:03 p.m. UTC | #8
> 2015-04-03 0:13 GMT+03:00 Jan Hubicka <hubicka@ucw.cz>:
> >> On 04/02/2015 02:11 PM, Jan Hubicka wrote:
> >> >>>2015-03-18  Ilya Enkovich  <ilya.enkovich@intel.com>
> >> >>>
> >> >>>         * cgraphunit.c (cgraph_node::expand_thunk): Don't expand
> >> >>>         instrumentation thunks.
> >> >>>
> >> >>>
> >> >>>diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> >> >>>index e640907..abc9cfe 100644
> >> >>>--- a/gcc/cgraphunit.c
> >> >>>+++ b/gcc/cgraphunit.c
> >> >>>@@ -1508,6 +1508,10 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
> >> >>>    tree thunk_fndecl = decl;
> >> >>>    tree a;
> >> >>>
> >> >>>+  /* Instrumentation thunk is the same function with
> >> >>>+     a different signature.  Never need to expand it.  */
> >> >>>+  if (thunk.add_pointer_bounds_args)
> >> >>>+    return false;
> >> >
> >> >Yeah, this is another case where we hit problem with transparent alias pretending
> >> >to be thunk :)
> >> >I guess the patch is OK for GCC-5 and for next stage1 we can clean this up.
> >> I was actually building a compiler so I could take a look at this
> >> one under a debugger ;-)
> >
> > I think it is really the transparent alias issue.  The comment seems pretty clear about it.
> > What is confusing is that instrumentation thunks are called thunks when they are
> > really not - thunk is a small hunk of code, while instrumentation thunk is a transparent
> > alias.
> >
> > Too bad I did not notice we introduced transparent aliases, i would push out my
> > code for that. I will compare Ilya's changes with mine and hopefully we can
> > catch more bugs and unify the code next stage1.
> 
> Thunk was the best I could find to represent the same function but
> with different signature. It would be great to have a more specialized
> way for that.

Yeah, that is also what we need for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61886
I just did not notice you are independently solving the same issue :(

Honza
diff mbox

Patch

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index e640907..abc9cfe 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1508,6 +1508,10 @@  cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
   tree thunk_fndecl = decl;
   tree a;
 
+  /* Instrumentation thunk is the same function with
+     a different signature.  Never need to expand it.  */
+  if (thunk.add_pointer_bounds_args)
+    return false;
 
   if (!force_gimple_thunk && this_adjusting
       && targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset,