diff mbox

Cgraph alias reorg 15/14 (New infrastructure for same body aliases)

Message ID 20110612145443.GA7920@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka June 12, 2011, 2:54 p.m. UTC
> 
> This also pretty much destroyed C++ for ia32:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49378
> http://gcc.gnu.org/ml/gcc-regression/2011-06/msg00159.html

Hi,
It seems somewhat amazing that we hit kernel sensitive miscompilation here.
The problem most probably is the fact that thunks and functions with thunks can become
local. This is correct since thunks are represented as direct calls now, but this
makes i386 to use local ABI when calling or compiling them.

Does the following patch help? We may also need to look for the presence of thunk
callers.

Comments

H.J. Lu June 12, 2011, 3:01 p.m. UTC | #1
On Sun, Jun 12, 2011 at 7:54 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>
>> This also pretty much destroyed C++ for ia32:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49378
>> http://gcc.gnu.org/ml/gcc-regression/2011-06/msg00159.html
>
> Hi,
> It seems somewhat amazing that we hit kernel sensitive miscompilation here.
> The problem most probably is the fact that thunks and functions with thunks can become
> local. This is correct since thunks are represented as direct calls now, but this
> makes i386 to use local ABI when calling or compiling them.
>
> Does the following patch help? We may also need to look for the presence of thunk
> callers.
>
> Index: ipa.c
> ===================================================================
> --- ipa.c       (revision 174958)
> +++ ipa.c       (working copy)
> @@ -120,6 +120,7 @@ static bool
>  cgraph_non_local_node_p_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
>  {
>    return !(cgraph_only_called_directly_or_aliased_p (node)
> +           && !ipa_ref_has_aliases_p (&node->ref_list)
>            && node->analyzed
>            && !DECL_EXTERNAL (node->decl)
>            && !node->local.externally_visible
> @@ -132,7 +133,11 @@ cgraph_non_local_node_p_1 (struct cgraph
>  static bool
>  cgraph_local_node_p (struct cgraph_node *node)
>  {
> -   return !cgraph_for_node_and_aliases (cgraph_function_or_thunk_node (node, NULL),
> +   struct cgraph_node *n = cgraph_function_or_thunk_node (node, NULL);
> +
> +   if (n->thunk.thunk_p)
> +     return false;
> +   return !cgraph_for_node_and_aliases (n,
>                                        cgraph_non_local_node_p_1, NULL, true);
>
>  }
>

I am testing it now.  Will know the results in 2 hours.

Thanks.
Jan Hubicka June 12, 2011, 3:08 p.m. UTC | #2
> I am testing it now.  Will know the results in 2 hours.
Thanks.
Could you also send me the preprocessed source for future.o?  The object file I
am getting don't have the bug you report, that is most probably due to glibc
difference.

Honza
> 
> Thanks.
> 
> -- 
> H.J.
H.J. Lu June 12, 2011, 3:55 p.m. UTC | #3
On Sun, Jun 12, 2011 at 7:54 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>
>> This also pretty much destroyed C++ for ia32:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49378
>> http://gcc.gnu.org/ml/gcc-regression/2011-06/msg00159.html
>
> Hi,
> It seems somewhat amazing that we hit kernel sensitive miscompilation here.
> The problem most probably is the fact that thunks and functions with thunks can become
> local. This is correct since thunks are represented as direct calls now, but this
> makes i386 to use local ABI when calling or compiling them.
>

For x86-64, we use the same ABI for local and global. But RAX seems
used and uninitialized in thunk.
H.J. Lu June 12, 2011, 4:27 p.m. UTC | #4
On Sun, Jun 12, 2011 at 8:01 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Jun 12, 2011 at 7:54 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>>
>>> This also pretty much destroyed C++ for ia32:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49378
>>> http://gcc.gnu.org/ml/gcc-regression/2011-06/msg00159.html
>>
>> Hi,
>> It seems somewhat amazing that we hit kernel sensitive miscompilation here.
>> The problem most probably is the fact that thunks and functions with thunks can become
>> local. This is correct since thunks are represented as direct calls now, but this
>> makes i386 to use local ABI when calling or compiling them.
>>
>> Does the following patch help? We may also need to look for the presence of thunk
>> callers.
>>
>> Index: ipa.c
>> ===================================================================
>> --- ipa.c       (revision 174958)
>> +++ ipa.c       (working copy)
>> @@ -120,6 +120,7 @@ static bool
>>  cgraph_non_local_node_p_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
>>  {
>>    return !(cgraph_only_called_directly_or_aliased_p (node)
>> +           && !ipa_ref_has_aliases_p (&node->ref_list)
>>            && node->analyzed
>>            && !DECL_EXTERNAL (node->decl)
>>            && !node->local.externally_visible
>> @@ -132,7 +133,11 @@ cgraph_non_local_node_p_1 (struct cgraph
>>  static bool
>>  cgraph_local_node_p (struct cgraph_node *node)
>>  {
>> -   return !cgraph_for_node_and_aliases (cgraph_function_or_thunk_node (node, NULL),
>> +   struct cgraph_node *n = cgraph_function_or_thunk_node (node, NULL);
>> +
>> +   if (n->thunk.thunk_p)
>> +     return false;
>> +   return !cgraph_for_node_and_aliases (n,
>>                                        cgraph_non_local_node_p_1, NULL, true);
>>
>>  }
>>
>
> I am testing it now.  Will know the results in 2 hours.
>

Yes, it fixes C++ regressions.

Thanks.
Jan Hubicka June 12, 2011, 4:33 p.m. UTC | #5
> On Sun, Jun 12, 2011 at 7:54 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> >>
> >> This also pretty much destroyed C++ for ia32:
> >>
> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49378
> >> http://gcc.gnu.org/ml/gcc-regression/2011-06/msg00159.html
> >
> > Hi,
> > It seems somewhat amazing that we hit kernel sensitive miscompilation here.
> > The problem most probably is the fact that thunks and functions with thunks can become
> > local. This is correct since thunks are represented as direct calls now, but this
> > makes i386 to use local ABI when calling or compiling them.
> >
> 
> For x86-64, we use the same ABI for local and global. But RAX seems
> used and uninitialized in thunk.
000000000006d270 <_ZN12_GLOBAL__N_121system_error_categoryD0Ev>:
   6d270:       48 8d 05 79 d4 27 00    lea    0x27d479(%rip),%rax        #
2ea6f0 <_ZTVN12_GLOBAL__N_121system_error_categoryE+0x10>
   6d277:       53                      push   %rbx
   6d278:       48 89 fb                mov    %rdi,%rbx
   6d27b:       48 89 07                mov    %rax,(%rdi)
   6d27e:       e8 55 a0 fe ff          callq  572d8
<_ZNSt14error_categoryD2Ev@plt>
   6d283:       48 89 df                mov    %rbx,%rdi
   6d286:       5b                      pop    %rbx
   6d287:       e9 2c 9d fe ff          jmpq   56fb8 <_ZdlPv@plt>
   6d28c:       90                      nop
   6d28d:       90                      nop
   6d28e:       90                      nop
   6d28f:       90                      nop

I don't see uinitialized RAX here.  It is set by the first LEA
I will commit the patch now to unbreak x86 and work on more proper solution after debugging
the plugin usses.

Thanks for testing!
Honza
> 
> -- 
> H.J.
H.J. Lu June 12, 2011, 5:06 p.m. UTC | #6
On Sun, Jun 12, 2011 at 9:33 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> On Sun, Jun 12, 2011 at 7:54 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> >>
>> >> This also pretty much destroyed C++ for ia32:
>> >>
>> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49378
>> >> http://gcc.gnu.org/ml/gcc-regression/2011-06/msg00159.html
>> >
>> > Hi,
>> > It seems somewhat amazing that we hit kernel sensitive miscompilation here.
>> > The problem most probably is the fact that thunks and functions with thunks can become
>> > local. This is correct since thunks are represented as direct calls now, but this
>> > makes i386 to use local ABI when calling or compiling them.
>> >
>>
>> For x86-64, we use the same ABI for local and global. But RAX seems
>> used and uninitialized in thunk.
> 000000000006d270 <_ZN12_GLOBAL__N_121system_error_categoryD0Ev>:
>   6d270:       48 8d 05 79 d4 27 00    lea    0x27d479(%rip),%rax        #
> 2ea6f0 <_ZTVN12_GLOBAL__N_121system_error_categoryE+0x10>
>   6d277:       53                      push   %rbx
>   6d278:       48 89 fb                mov    %rdi,%rbx
>   6d27b:       48 89 07                mov    %rax,(%rdi)
>   6d27e:       e8 55 a0 fe ff          callq  572d8
> <_ZNSt14error_categoryD2Ev@plt>
>   6d283:       48 89 df                mov    %rbx,%rdi
>   6d286:       5b                      pop    %rbx
>   6d287:       e9 2c 9d fe ff          jmpq   56fb8 <_ZdlPv@plt>
>   6d28c:       90                      nop
>   6d28d:       90                      nop
>   6d28e:       90                      nop
>   6d28f:       90                      nop
>
> I don't see uinitialized RAX here.  It is set by the first LEA

You are right.
diff mbox

Patch

Index: ipa.c
===================================================================
--- ipa.c	(revision 174958)
+++ ipa.c	(working copy)
@@ -120,6 +120,7 @@  static bool
 cgraph_non_local_node_p_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
 {
    return !(cgraph_only_called_directly_or_aliased_p (node)
+	    && !ipa_ref_has_aliases_p (&node->ref_list)
 	    && node->analyzed
 	    && !DECL_EXTERNAL (node->decl)
 	    && !node->local.externally_visible
@@ -132,7 +133,11 @@  cgraph_non_local_node_p_1 (struct cgraph
 static bool
 cgraph_local_node_p (struct cgraph_node *node)
 {
-   return !cgraph_for_node_and_aliases (cgraph_function_or_thunk_node (node, NULL),
+   struct cgraph_node *n = cgraph_function_or_thunk_node (node, NULL);
+   
+   if (n->thunk.thunk_p)
+     return false;
+   return !cgraph_for_node_and_aliases (n,
 					cgraph_non_local_node_p_1, NULL, true);
 					
 }