public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/62180] New: (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access
@ 2014-08-19 8:20 jan.capek at braiins dot cz
2014-08-19 8:24 ` [Bug target/62180] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jan.capek at braiins dot cz @ 2014-08-19 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62180
Bug ID: 62180
Summary: (RX600) - compiler doesn't honor
-fstrict-volatile-bitfields and generates incorrect
machine code for I/O register access
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jan.capek at braiins dot cz
Created attachment 33359
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33359&action=edit
broken output from gcc 4.9.0
I have come across this issue while testing 4.9.x series of the compiler with
Renesas RX600 target
The compiler now generates byte accesses when writing bitfields completely
ignoring their 'type'. The strict-volatile-bitfields options seems to have no
effect. Our original compiler version 4.7.2 seems to work correctly and
generates accesses to the bitfields based on their type. This is essentially
what the documentation for the 'strict-volatile-bitfields' says.
I have tested this with 4.8.2 and 4.8.3, too with the same result. The test
case demonstrates access to a 16-bit memory mapped peripheral register. It is
absolutely necessary that the register is always being written in 16-bit
quantities.
A simple testcase:
struct st_cmt0 {
union {
unsigned short WORD;
struct {
volatile unsigned short CKS:2;
volatile unsigned short :4;
volatile unsigned short CMIE:1;
volatile unsigned short :9;
} BIT;
} CMCR;
unsigned short CMCNT;
unsigned short CMCOR;
};
void test(volatile struct st_cmt0 *reg)
{
reg->CMCR.BIT.CMIE = 1;
}
The output for gcc 4.7.2 is:
.file "test.c"
.section P,"ax"
.global _test
.type _test, @function
_test:
pushm r6-r11
add #-4, r0, r6
mov.L r6, r0
mov.L r1, [r6]
mov.L [r6], r11
mov.W [r11], r10 ; HONORS the 16-bit register size
bset #6, r10
mov.W r10, [r11] ; HONORS the 16-bit register size
rtsd #28, r6-r11
.size _test, .-_test
.ident "GCC: (GNU) 4.7.2"
The output for gcc 4.9.0 is:
.file "test.c"
.section P,"ax"
.global _test
.type _test, @function
_test:
pushm r6-r11
add #-4, r0, r6
mov.L r6, r0
mov.L r1, [r6]
mov.L [r6], r11
mov.B [r11], r10 ; broken - reads only part of the register
bset #6, r10
mov.B r10, [r11] ; broken - writes only part of the register
rtsd #28, r6-r11
.size _test, .-_test
.ident "GCC: (GNU) 4.9.0"
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/62180] (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access
2014-08-19 8:20 [Bug target/62180] New: (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access jan.capek at braiins dot cz
@ 2014-08-19 8:24 ` pinskia at gcc dot gnu.org
2014-08-19 8:32 ` jan.capek at braiins dot cz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-08-19 8:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62180
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|wrong-code |
Target|Renesas RX600 |
Known to work|4.7.2 |
Host|linux amd64 |
Known to fail|4.9.0 |
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
C11 says something different here.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/62180] (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access
2014-08-19 8:20 [Bug target/62180] New: (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access jan.capek at braiins dot cz
2014-08-19 8:24 ` [Bug target/62180] " pinskia at gcc dot gnu.org
@ 2014-08-19 8:32 ` jan.capek at braiins dot cz
2014-08-19 16:28 ` dj at redhat dot com
2014-08-20 7:22 ` jan.capek at braiins dot cz
3 siblings, 0 replies; 5+ messages in thread
From: jan.capek at braiins dot cz @ 2014-08-19 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62180
--- Comment #2 from Jan Čapek <jan.capek at braiins dot cz> ---
(In reply to Andrew Pinski from comment #1)
> C11 says something different here.
Can you be a bit more specific?
>From gcc-bugs-return-458755-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Aug 19 08:41:03 2014
Return-Path: <gcc-bugs-return-458755-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 11542 invoked by alias); 19 Aug 2014 08:41:03 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 11510 invoked by uid 48); 19 Aug 2014 08:40:53 -0000
From: "jan.capek at braiins dot cz" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/62180] (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access
Date: Tue, 19 Aug 2014 08:41:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jan.capek at braiins dot cz
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-62180-4-YGIREuLycu@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62180-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62180-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg01252.txt.bz2
Content-length: 748
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62180
--- Comment #3 from Jan Čapek <jan.capek at braiins dot cz> ---
(In reply to Andrew Pinski from comment #1)
> C11 says something different here.
I can see the following the -fstrict-volatile-bitfields documentation:
"This option should be used if accesses to volatile bit-fields (or other
structure fields, although the compiler usually honors those types anyway)
should use a single access of the width of the field's type, aligned to a
natural alignment if possible."
And this is actually the case with gcc 4.7.2, it ignore the -fstrict....
option, and also doesn't need volatile on the individual bit-fields and it
still generates correct code due to specifying the bitfield types.
>From gcc-bugs-return-458756-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Aug 19 08:54:04 2014
Return-Path: <gcc-bugs-return-458756-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20216 invoked by alias); 19 Aug 2014 08:54:04 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20183 invoked by uid 48); 19 Aug 2014 08:53:59 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/62179] undefined reference linking failure when combining "extern template"
Date: Tue, 19 Aug 2014 08:54:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-62179-4-C5QADEvb1V@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62179-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62179-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg01253.txt.bz2
Content-length: 518
https://gcc.gnu.org/bugzilla/show_bug.cgi?idb179
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2014-08-19
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Waiting for ... the bugreport? Testcase?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/62180] (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access
2014-08-19 8:20 [Bug target/62180] New: (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access jan.capek at braiins dot cz
2014-08-19 8:24 ` [Bug target/62180] " pinskia at gcc dot gnu.org
2014-08-19 8:32 ` jan.capek at braiins dot cz
@ 2014-08-19 16:28 ` dj at redhat dot com
2014-08-20 7:22 ` jan.capek at braiins dot cz
3 siblings, 0 replies; 5+ messages in thread
From: dj at redhat dot com @ 2014-08-19 16:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62180
DJ Delorie <dj at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dj at redhat dot com
--- Comment #4 from DJ Delorie <dj at redhat dot com> ---
Perhaps you need this patch:
https://gcc.gnu.org/ml/gcc-patches/2014-06/msg00993.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/62180] (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access
2014-08-19 8:20 [Bug target/62180] New: (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access jan.capek at braiins dot cz
` (2 preceding siblings ...)
2014-08-19 16:28 ` dj at redhat dot com
@ 2014-08-20 7:22 ` jan.capek at braiins dot cz
3 siblings, 0 replies; 5+ messages in thread
From: jan.capek at braiins dot cz @ 2014-08-20 7:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62180
--- Comment #5 from Jan Čapek <jan.capek at braiins dot cz> ---
(In reply to DJ Delorie from comment #4)
> Perhaps you need this patch:
>
> https://gcc.gnu.org/ml/gcc-patches/2014-06/msg00993.html
DJ Delorie,
you are the man! The patch works as expected. Interestingly, the compiler now
honors the bitfield sizes even without explicitely specifying this options. The
resulting machine code output is:
.file "test.c"
.section P,"ax"
.global _test
.type _test, @function
_test:
pushm r6-r11
add #-4, r0, r6
mov.L r6, r0
mov.L r1, [r6]
mov.L [r6], r10
mov.W [r10], r11 ; YES, read the entire register
or #64, r11
mov.W r11, [r10] ; YES, write the entire register
rtsd #28, r6-r11
.size _test, .-_test
.ident "GCC: (GNU) 4.9.0"
I have checked the 4.9 official branch and it still has not been included will
it go to the trunk/master branch?
Thanks again,
Jan
>From gcc-bugs-return-458839-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Aug 20 07:26:33 2014
Return-Path: <gcc-bugs-return-458839-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 18550 invoked by alias); 20 Aug 2014 07:26:32 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 18532 invoked by uid 48); 20 Aug 2014 07:26:28 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/62199] ICE with -Wlogical-not-parentheses
Date: Wed, 20 Aug 2014 07:26:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on assigned_to target_milestone everconfirmed
Message-ID: <bug-62199-4-mHVc9QTAfE@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62199-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62199-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg01336.txt.bz2
Content-length: 620
https://gcc.gnu.org/bugzilla/show_bug.cgi?idb199
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-08-20
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Target Milestone|--- |5.0
Ever confirmed|0 |1
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Mine.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-20 7:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19 8:20 [Bug target/62180] New: (RX600) - compiler doesn't honor -fstrict-volatile-bitfields and generates incorrect machine code for I/O register access jan.capek at braiins dot cz
2014-08-19 8:24 ` [Bug target/62180] " pinskia at gcc dot gnu.org
2014-08-19 8:32 ` jan.capek at braiins dot cz
2014-08-19 16:28 ` dj at redhat dot com
2014-08-20 7:22 ` jan.capek at braiins dot cz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).