Patchwork {patch ira-color.c]: Fix printf-formatter use for long-long type for windows native targets.

login
register
mail settings
Submitter Kai Tietz
Date Dec. 9, 2011, 8:51 a.m.
Message ID <CAEwic4aJcyB8C5L9kicNVBh1azpGRn7tjb+5NLnVa+y_39z-Wg@mail.gmail.com>
Download mbox | patch
Permalink /patch/130321/
State New
Headers show

Comments

Kai Tietz - Dec. 9, 2011, 8:51 a.m.
Hi,

this patch fixes for windows native target print-formatter used about
long-long type.

ChangeLog

2011-12-09  Kai Tietz  <ktietz@redhat.com>

	* ira-color.c (print_hard_regs_subforest): Use
	HOST_WIDEST_INT_PRINT_DEC instead of %lld.

Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
x86_64-unknown-linux-gnu.  Ok for apply?

Kai
Richard Guenther - Dec. 9, 2011, 9:48 a.m.
On Fri, Dec 9, 2011 at 9:51 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hi,
>
> this patch fixes for windows native target print-formatter used about
> long-long type.
>
> ChangeLog
>
> 2011-12-09  Kai Tietz  <ktietz@redhat.com>
>
>        * ira-color.c (print_hard_regs_subforest): Use
>        HOST_WIDEST_INT_PRINT_DEC instead of %lld.
>
> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
> x86_64-unknown-linux-gnu.  Ok for apply?

Hm?  struct allocno_hard_regs uses a long long int cost member,
so why is %lld wrong?  If it doesn't work then you should change
the cost member to use HOST_WIDEST_INT as well I guess
(and verify all (indirect) uses).

Richard.

> Kai
>
> Index: ira-color.c
> ===================================================================
> --- ira-color.c (revision 182092)
> +++ ira-color.c (working copy)
> @@ -498,7 +498,8 @@
>        fprintf (f, " ");
>       fprintf (f, "%d:(", node->preorder_num);
>       print_hard_reg_set (f, node->hard_regs->set, false);
> -      fprintf (f, ")@%lld\n", node->hard_regs->cost);
> +      fprintf (f, ")@" HOST_WIDEST_INT_PRINT_DEC "\n",
> +              (HOST_WIDEST_INT) node->hard_regs->cost);
>       print_hard_regs_subforest (f, node->first, level + 1);
>     }
>  }
Kai Tietz - Dec. 9, 2011, 9:58 a.m.
2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
> On Fri, Dec 9, 2011 at 9:51 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> Hi,
>>
>> this patch fixes for windows native target print-formatter used about
>> long-long type.
>>
>> ChangeLog
>>
>> 2011-12-09  Kai Tietz  <ktietz@redhat.com>
>>
>>        * ira-color.c (print_hard_regs_subforest): Use
>>        HOST_WIDEST_INT_PRINT_DEC instead of %lld.
>>
>> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
>> x86_64-unknown-linux-gnu.  Ok for apply?
>
> Hm?  struct allocno_hard_regs uses a long long int cost member,
> so why is %lld wrong?  If it doesn't work then you should change
> the cost member to use HOST_WIDEST_INT as well I guess
> (and verify all (indirect) uses).
>
> Richard.

Issue is that the printf-formatter %ll doesn't necessarily is present
for windows native targets.  For these targets the formatter is %I64
here instead.

Kai
Richard Guenther - Dec. 9, 2011, 10:03 a.m.
On Fri, Dec 9, 2011 at 10:58 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>> On Fri, Dec 9, 2011 at 9:51 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> Hi,
>>>
>>> this patch fixes for windows native target print-formatter used about
>>> long-long type.
>>>
>>> ChangeLog
>>>
>>> 2011-12-09  Kai Tietz  <ktietz@redhat.com>
>>>
>>>        * ira-color.c (print_hard_regs_subforest): Use
>>>        HOST_WIDEST_INT_PRINT_DEC instead of %lld.
>>>
>>> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
>>> x86_64-unknown-linux-gnu.  Ok for apply?
>>
>> Hm?  struct allocno_hard_regs uses a long long int cost member,
>> so why is %lld wrong?  If it doesn't work then you should change
>> the cost member to use HOST_WIDEST_INT as well I guess
>> (and verify all (indirect) uses).
>>
>> Richard.
>
> Issue is that the printf-formatter %ll doesn't necessarily is present
> for windows native targets.  For these targets the formatter is %I64
> here instead.

We seem to have HOST_LONG_LONG_FORMAT, why not use that?

> Kai
Kai Tietz - Dec. 9, 2011, 10:10 a.m.
2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
> On Fri, Dec 9, 2011 at 10:58 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>>> On Fri, Dec 9, 2011 at 9:51 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>> Hi,
>>>>
>>>> this patch fixes for windows native target print-formatter used about
>>>> long-long type.
>>>>
>>>> ChangeLog
>>>>
>>>> 2011-12-09  Kai Tietz  <ktietz@redhat.com>
>>>>
>>>>        * ira-color.c (print_hard_regs_subforest): Use
>>>>        HOST_WIDEST_INT_PRINT_DEC instead of %lld.
>>>>
>>>> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
>>>> x86_64-unknown-linux-gnu.  Ok for apply?
>>>
>>> Hm?  struct allocno_hard_regs uses a long long int cost member,
>>> so why is %lld wrong?  If it doesn't work then you should change
>>> the cost member to use HOST_WIDEST_INT as well I guess
>>> (and verify all (indirect) uses).
>>>
>>> Richard.
>>
>> Issue is that the printf-formatter %ll doesn't necessarily is present
>> for windows native targets.  For these targets the formatter is %I64
>> here instead.
>
> We seem to have HOST_LONG_LONG_FORMAT, why not use that?

Well, HOST_LONG_LONG_FORMAT just specifies here the "ll"/"I64".  Sure,
we can use it here, too.  But as HOST_WIDEST_INT_PRINT_DEC is defined
as '"%" HOST_LONG_LONG_FORMAT "d", and other places are using it for
this purpose, too, it looks to me more sane to use here the
HOST_WIDEST_INT_PRINT_DEC directly.

Kai
Richard Guenther - Dec. 9, 2011, 10:19 a.m.
On Fri, Dec 9, 2011 at 11:10 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>> On Fri, Dec 9, 2011 at 10:58 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>>>> On Fri, Dec 9, 2011 at 9:51 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>>> Hi,
>>>>>
>>>>> this patch fixes for windows native target print-formatter used about
>>>>> long-long type.
>>>>>
>>>>> ChangeLog
>>>>>
>>>>> 2011-12-09  Kai Tietz  <ktietz@redhat.com>
>>>>>
>>>>>        * ira-color.c (print_hard_regs_subforest): Use
>>>>>        HOST_WIDEST_INT_PRINT_DEC instead of %lld.
>>>>>
>>>>> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
>>>>> x86_64-unknown-linux-gnu.  Ok for apply?
>>>>
>>>> Hm?  struct allocno_hard_regs uses a long long int cost member,
>>>> so why is %lld wrong?  If it doesn't work then you should change
>>>> the cost member to use HOST_WIDEST_INT as well I guess
>>>> (and verify all (indirect) uses).
>>>>
>>>> Richard.
>>>
>>> Issue is that the printf-formatter %ll doesn't necessarily is present
>>> for windows native targets.  For these targets the formatter is %I64
>>> here instead.
>>
>> We seem to have HOST_LONG_LONG_FORMAT, why not use that?
>
> Well, HOST_LONG_LONG_FORMAT just specifies here the "ll"/"I64".  Sure,
> we can use it here, too.  But as HOST_WIDEST_INT_PRINT_DEC is defined
> as '"%" HOST_LONG_LONG_FORMAT "d", and other places are using it for
> this purpose, too, it looks to me more sane to use here the
> HOST_WIDEST_INT_PRINT_DEC directly.

Not on a 'long long int' type though (the use of 'long long' is
questionable anyway, given it's not in C89 nor C++98).

Richard.

> Kai
Kai Tietz - Dec. 9, 2011, 10:32 a.m.
2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
> On Fri, Dec 9, 2011 at 11:10 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>>> On Fri, Dec 9, 2011 at 10:58 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>>>>> On Fri, Dec 9, 2011 at 9:51 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> this patch fixes for windows native target print-formatter used about
>>>>>> long-long type.
>>>>>>
>>>>>> ChangeLog
>>>>>>
>>>>>> 2011-12-09  Kai Tietz  <ktietz@redhat.com>
>>>>>>
>>>>>>        * ira-color.c (print_hard_regs_subforest): Use
>>>>>>        HOST_WIDEST_INT_PRINT_DEC instead of %lld.
>>>>>>
>>>>>> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
>>>>>> x86_64-unknown-linux-gnu.  Ok for apply?
>>>>>
>>>>> Hm?  struct allocno_hard_regs uses a long long int cost member,
>>>>> so why is %lld wrong?  If it doesn't work then you should change
>>>>> the cost member to use HOST_WIDEST_INT as well I guess
>>>>> (and verify all (indirect) uses).
>>>>>
>>>>> Richard.
>>>>
>>>> Issue is that the printf-formatter %ll doesn't necessarily is present
>>>> for windows native targets.  For these targets the formatter is %I64
>>>> here instead.
>>>
>>> We seem to have HOST_LONG_LONG_FORMAT, why not use that?
>>
>> Well, HOST_LONG_LONG_FORMAT just specifies here the "ll"/"I64".  Sure,
>> we can use it here, too.  But as HOST_WIDEST_INT_PRINT_DEC is defined
>> as '"%" HOST_LONG_LONG_FORMAT "d", and other places are using it for
>> this purpose, too, it looks to me more sane to use here the
>> HOST_WIDEST_INT_PRINT_DEC directly.
>
> Not on a 'long long int' type though (the use of 'long long' is
> questionable anyway, given it's not in C89 nor C++98).
>
> Richard.

Yes, the use of long long might be an extension in specific C/C++
standards.  But isn't that exactly a reason to use HOST_WIDEST_INT
type?  As it allows at least to mark that type (if required) as
__extension__?

Kai
Richard Guenther - Dec. 9, 2011, 10:34 a.m.
On Fri, Dec 9, 2011 at 11:32 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>> On Fri, Dec 9, 2011 at 11:10 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>>>> On Fri, Dec 9, 2011 at 10:58 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>>> 2011/12/9 Richard Guenther <richard.guenther@gmail.com>:
>>>>>> On Fri, Dec 9, 2011 at 9:51 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> this patch fixes for windows native target print-formatter used about
>>>>>>> long-long type.
>>>>>>>
>>>>>>> ChangeLog
>>>>>>>
>>>>>>> 2011-12-09  Kai Tietz  <ktietz@redhat.com>
>>>>>>>
>>>>>>>        * ira-color.c (print_hard_regs_subforest): Use
>>>>>>>        HOST_WIDEST_INT_PRINT_DEC instead of %lld.
>>>>>>>
>>>>>>> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and
>>>>>>> x86_64-unknown-linux-gnu.  Ok for apply?
>>>>>>
>>>>>> Hm?  struct allocno_hard_regs uses a long long int cost member,
>>>>>> so why is %lld wrong?  If it doesn't work then you should change
>>>>>> the cost member to use HOST_WIDEST_INT as well I guess
>>>>>> (and verify all (indirect) uses).
>>>>>>
>>>>>> Richard.
>>>>>
>>>>> Issue is that the printf-formatter %ll doesn't necessarily is present
>>>>> for windows native targets.  For these targets the formatter is %I64
>>>>> here instead.
>>>>
>>>> We seem to have HOST_LONG_LONG_FORMAT, why not use that?
>>>
>>> Well, HOST_LONG_LONG_FORMAT just specifies here the "ll"/"I64".  Sure,
>>> we can use it here, too.  But as HOST_WIDEST_INT_PRINT_DEC is defined
>>> as '"%" HOST_LONG_LONG_FORMAT "d", and other places are using it for
>>> this purpose, too, it looks to me more sane to use here the
>>> HOST_WIDEST_INT_PRINT_DEC directly.
>>
>> Not on a 'long long int' type though (the use of 'long long' is
>> questionable anyway, given it's not in C89 nor C++98).
>>
>> Richard.
>
> Yes, the use of long long might be an extension in specific C/C++
> standards.  But isn't that exactly a reason to use HOST_WIDEST_INT
> type?  As it allows at least to mark that type (if required) as
> __extension__?

Your patch doesn't change the type of allocno_hard_regs.cost

> Kai

Patch

Index: ira-color.c
===================================================================
--- ira-color.c (revision 182092)
+++ ira-color.c (working copy)
@@ -498,7 +498,8 @@ 
        fprintf (f, " ");
       fprintf (f, "%d:(", node->preorder_num);
       print_hard_reg_set (f, node->hard_regs->set, false);
-      fprintf (f, ")@%lld\n", node->hard_regs->cost);
+      fprintf (f, ")@" HOST_WIDEST_INT_PRINT_DEC "\n",
+              (HOST_WIDEST_INT) node->hard_regs->cost);
       print_hard_regs_subforest (f, node->first, level + 1);
     }
 }