PR 88409: miscompilation due to missing cc clobber in longlong.h macros
PATCH 1/1 PR 88409: miscompilation due to missing cc clobber in longlong.h macros
simple test such as below was failing.
| void main(int argc, char *argv[])
| {
| size_t total_time = 115424; // expected 115.424
| double secs = (double)total_time/(double)1000;
| printf("%s %d %lf\n", "secs", total_time, secs); // prints 113.504
| printf("%d\n", (size_t)secs);
| }The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem() which uses the __arc__ specific inline asm macros from longlong.h which were causing miscompilation.
include/
2019-03-28 Vineet Gupta <vgupta at synopsys.com>
PR 89877 * longlong.h [__arc__] (add_ssaaaa): Add cc clobber (sub_ddmmss): Likewise.
--- include/ChangeLog | 7 +++++++ include/longlong.h | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
include/ChangeLog +7 -0
@@ -1,3 +1,10 @@ +2019-03-28 Vineet Gupta <vgupta at synopsys.com> + + PR 89877 + + * longlong.h [__arc__] (add_ssaaaa): Add cc clobber + (sub_ddmmss): Likewise. + 2019-02-11 Philippe Waroquiers <philippe.waroquiers at skynet.be> * splay-tree.h (splay_tree_delete_key_fn): Update comment.
include/longlong.h +4 -2
@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "%r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "%r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define sub_ddmmss (sh, sl, ah, al, bh, bl) \ __asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \ : "=r" ((USItype) (sh)), \
@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define __umulsidi3 (u,v) ((UDItype)(USItype)u*(USItype)v)#ifdef __ARC_NORM__
Signature · 1 line
2.7.4
PATCH 1/1 PR 88409: miscompilation due to missing cc clobber in longlong.h macros
Pushed, thank you for your contribution,
Claudiu
Quoted 71 lines · Vineet Gupta
simple test such as below was failing.
| void main(int argc, char *argv[]) | { | size_t total_time = 115424; // expected 115.424 | double secs = (double)total_time/(double)1000; | printf("%s %d %lf\n", "secs", total_time, secs); // prints 113.504 | printf("%d\n", (size_t)secs); | }The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem() which uses the
__arc__specific inline asm macros fromlonglong.hwhich were causing miscompilation.
include/
2019-03-28 Vineet Gupta <vgupta at synopsys.com>PR 89877
*
longlong.h[__arc__] (add_ssaaaa): Add cc clobber (sub_ddmmss): Likewise.Signed-off-by Vineet Gupta <vgupta at synopsys.com>--- include/ChangeLog | 7 +++++++ include/longlong.h | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-)include/ChangeLog +7
-0@@ -1,3 +1,10 @@ +2019-03-28 Vineet Gupta <vgupta at synopsys.com> + + PR 89877 + + * longlong.h [__arc__] (add_ssaaaa): Add cc clobber + (sub_ddmmss): Likewise. + 2019-02-11 Philippe Waroquiers <philippe.waroquiers at skynet.be> * splay-tree.h (splay_tree_delete_key_fn): Update comment.include/longlong.h +4
-3@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "%r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "%r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define sub_ddmmss (sh, sl, ah, al, bh, bl) \ __asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \ : "=r" ((USItype) (sh)), \@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define __umulsidi3 (u,v) ((UDItype)(USItype)u*(USItype)v)#ifdef __ARC_NORM__ --2.7.4
PATCH 1/1 PR 88409: miscompilation due to missing cc clobber in longlong.h macros
Quoted 2 lines · Claudiu Zissulescu
Pushed, thank you for your contribution,
Claudiu
Thx, can this be backported to gcc-8-stable please which is what glibc folks use for testing !
-Vineet
Quoted 72 lines · Vineet Gupta
Quoted 70 lines
simple test such as below was failing.
| void main(int argc, char *argv[]) | { | size_t total_time = 115424; // expected 115.424 | double secs = (double)total_time/(double)1000; | printf("%s %d %lf\n", "secs", total_time, secs); // prints 113.504 | printf("%d\n", (size_t)secs); | }The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem() which uses the
__arc__specific inline asm macros fromlonglong.hwhich were causing miscompilation.
include/
2019-03-28 Vineet Gupta <vgupta at synopsys.com>PR 89877
*
longlong.h[__arc__] (add_ssaaaa): Add cc clobber (sub_ddmmss): Likewise.Signed-off-by Vineet Gupta <vgupta at synopsys.com>--- include/ChangeLog | 7 +++++++ include/longlong.h | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-)include/ChangeLog +7
-0@@ -1,3 +1,10 @@ +2019-03-28 Vineet Gupta <vgupta at synopsys.com> + + PR 89877 + + * longlong.h [__arc__] (add_ssaaaa): Add cc clobber + (sub_ddmmss): Likewise. + 2019-02-11 Philippe Waroquiers <philippe.waroquiers at skynet.be> * splay-tree.h (splay_tree_delete_key_fn): Update comment.include/longlong.h +4
-3@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "%r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "%r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define sub_ddmmss (sh, sl, ah, al, bh, bl) \ __asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \ : "=r" ((USItype) (sh)), \@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define __umulsidi3 (u,v) ((UDItype)(USItype)u*(USItype)v)#ifdef __ARC_NORM__ --2.7.4
PATCH 1/1 PR 88409: miscompilation due to missing cc clobber in longlong.h macros
Done.
Quoted 83 lines · Vineet Gupta
Quoted 2 lines · Claudiu Zissulescu
Pushed, thank you for your contribution,
ClaudiuThx, can this be backported to gcc-8-stable please which is what glibc folks use for testing !
-Vineet
Quoted 72 lines · Vineet Gupta
Quoted 70 lines
simple test such as below was failing.
| void main(int argc, char *argv[]) | { | size_t total_time = 115424; // expected 115.424 | double secs = (double)total_time/(double)1000; | printf("%s %d %lf\n", "secs", total_time, secs); // prints 113.504 | printf("%d\n", (size_t)secs); | }The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem() which uses the
__arc__specific inline asm macros fromlonglong.hwhich were causing miscompilation.
include/
2019-03-28 Vineet Gupta <vgupta at synopsys.com>PR 89877
*
longlong.h[__arc__] (add_ssaaaa): Add cc clobber (sub_ddmmss): Likewise.Signed-off-by Vineet Gupta <vgupta at synopsys.com>--- include/ChangeLog | 7 +++++++ include/longlong.h | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-)include/ChangeLog +7
-0@@ -1,3 +1,10 @@ +2019-03-28 Vineet Gupta <vgupta at synopsys.com> + + PR 89877 + + * longlong.h [__arc__] (add_ssaaaa): Add cc clobber + (sub_ddmmss): Likewise. + 2019-02-11 Philippe Waroquiers <philippe.waroquiers at skynet.be> * splay-tree.h (splay_tree_delete_key_fn): Update comment.include/longlong.h +4
-3@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "%r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "%r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define sub_ddmmss (sh, sl, ah, al, bh, bl) \ __asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \ : "=r" ((USItype) (sh)), \@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); : "r" ((USItype) (ah)), \ "rICal" ((USItype) (bh)), \ "r" ((USItype) (al)), \ - "rICal" ((USItype) (bl))) + "rICal" ((USItype) (bl)) \ + : "cc")#define __umulsidi3 (u,v) ((UDItype)(USItype)u*(USItype)v)#ifdef __ARC_NORM__ --2.7.4