public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/43700] New: global register variables defect
@ 2010-04-09 9:31 steffenschmidt dot ext at siemens dot com
2010-04-09 9:50 ` [Bug target/43700] " rguenth at gcc dot gnu dot org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: steffenschmidt dot ext at siemens dot com @ 2010-04-09 9:31 UTC (permalink / raw)
To: gcc-bugs
We're making use of global register variables, which work fine in GCC version
4.3.2 and 4.3.3. GCC 4.4.1 and 4.4.3 however produce slightly different code,
which seems to be incorrect.
A brief example is:
//---------------test_register_call.c-------------------
register unsigned long long *g_reg_counter asm("$20");
void register_add (void)
{
*g_reg_counter++;
}
//---------------test_register_call.c-------------------
Compiled with:
mips-elf-gcc.exe -save-temps test_register_call.c
This produces the following assembler file using GCC 4.3.2
//---------------test_register_call_4.3.2.s-------------
.file 1 "test_register_call.c"
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.text
.align 2
.globl register_add
.set nomips16
.ent register_add
register_add:
.frame $fp,8,$31 # vars= 0, regs= 1/0, args= 0, gp= 0
.mask 0x40000000,-4
.fmask 0x00000000,0
.set noreorder
.set nomacro
addiu $sp,$sp,-8
sw $fp,4($sp)
move $fp,$sp
move $2,$20
addiu $2,$2,8
move $20,$2
move $sp,$fp
lw $fp,4($sp)
addiu $sp,$sp,8
j $31
nop
.set macro
.set reorder
.end register_add
.size register_add, .-register_add
.ident "GCC: 4.3.2"
//---------------test_register_call_4.3.2.s-------------
GCC 4.4.1 produces different assembly code (lines are marked):
//---------------test_register_call_4.4.1.s-------------
.file 1 "test_register_call.c"
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.text
.align 2
.globl register_add
.set nomips16
.ent register_add
.type register_add, @function
register_add:
.frame $fp,8,$31 # vars= 0, regs= 2/0, args= 0, gp= 0
.mask 0x40100000,-4
.fmask 0x00000000,0
.set noreorder
.set nomacro
addiu $sp,$sp,-8
sw $fp,4($sp)
sw $20,0($sp) # <== $20 is stored to stack
move $fp,$sp
move $2,$20
addiu $2,$2,8
move $20,$2
move $sp,$fp
lw $fp,4($sp)
lw $20,0($sp) # <== $20 is restored from stack
addiu $sp,$sp,8
j $31
nop
.set macro
.set reorder
.end register_add
.size register_add, .-register_add
.ident "GCC: 4.4.1"
//---------------test_register_call_4.4.1.s-------------
As can be seen in the example, MIPS register $20 is the global variable
register. The variable is modified in the function and the register should
therefore not be saved and restored. GCC 4.3.2 seems to be correct here. GCC
4.4.1, however, stores and restores the register $20 content.
--
Summary: global register variables defect
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: steffenschmidt dot ext at siemens dot com
GCC build triplet: i686-mingw32
GCC host triplet: i686-mingw32
GCC target triplet: mips-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
@ 2010-04-09 9:50 ` rguenth at gcc dot gnu dot org
2010-04-09 18:13 ` pinskia at gcc dot gnu dot org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-09 9:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2010-04-09 09:50 -------
Must be a target issue, can't reproduce this on x86_64 with
register unsigned long *g_reg_counter asm("%r10");
void register_add (void)
{
*g_reg_counter++;
}
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |target
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
2010-04-09 9:50 ` [Bug target/43700] " rguenth at gcc dot gnu dot org
@ 2010-04-09 18:13 ` pinskia at gcc dot gnu dot org
2010-04-09 18:21 ` [Bug target/43700] [4.4/4.5/4.6 Regression] " pinskia at gcc dot gnu dot org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-04-09 18:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2010-04-09 18:12 -------
Well $20 is a callee save register.
The back-end emits a save for some reason ...
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |target
Keywords| |wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
2010-04-09 9:50 ` [Bug target/43700] " rguenth at gcc dot gnu dot org
2010-04-09 18:13 ` pinskia at gcc dot gnu dot org
@ 2010-04-09 18:21 ` pinskia at gcc dot gnu dot org
2010-04-09 21:52 ` pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-04-09 18:21 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
GCC build triplet|i686-mingw32 |
GCC host triplet|i686-mingw32 |
GCC target triplet|mips-elf |mips*-*
Summary|global register variables |[4.4/4.5/4.6 Regression]
|defect |global register variables
| |defect
Target Milestone|--- |4.4.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (2 preceding siblings ...)
2010-04-09 18:21 ` [Bug target/43700] [4.4/4.5/4.6 Regression] " pinskia at gcc dot gnu dot org
@ 2010-04-09 21:52 ` pinskia at gcc dot gnu dot org
2010-04-12 8:41 ` jakub at gcc dot gnu dot org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-04-09 21:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2010-04-09 21:52 -------
Confirmed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-04-09 21:52:01
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (3 preceding siblings ...)
2010-04-09 21:52 ` pinskia at gcc dot gnu dot org
@ 2010-04-12 8:41 ` jakub at gcc dot gnu dot org
2010-04-12 9:03 ` mikpe at it dot uu dot se
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-04-12 8:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jakub at gcc dot gnu dot org 2010-04-12 08:41 -------
Isn't this just a user error then? You should have used -ffixed-20 if you use
a call saved register as global register IMHO.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (4 preceding siblings ...)
2010-04-12 8:41 ` jakub at gcc dot gnu dot org
@ 2010-04-12 9:03 ` mikpe at it dot uu dot se
2010-04-12 18:18 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mikpe at it dot uu dot se @ 2010-04-12 9:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from mikpe at it dot uu dot se 2010-04-12 09:02 -------
(In reply to comment #4)
> Isn't this just a user error then? You should have used -ffixed-20 if you use
> a call saved register as global register IMHO.
gcc's documentation (I'm looking at the global register variables node in 4.5's
extend.texi) states that passing -ffixed-reg is only needed if the translation
unit doesn't contain a declaration of that global register variable.
In this PR's test case the declaration is present, so -ffixed-20 should not be
needed.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (5 preceding siblings ...)
2010-04-12 9:03 ` mikpe at it dot uu dot se
@ 2010-04-12 18:18 ` pinskia at gcc dot gnu dot org
2010-04-12 18:20 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-04-12 18:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2010-04-12 18:18 -------
*** Bug 43732 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lance604 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (6 preceding siblings ...)
2010-04-12 18:18 ` pinskia at gcc dot gnu dot org
@ 2010-04-12 18:20 ` pinskia at gcc dot gnu dot org
2010-04-15 14:06 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-04-12 18:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pinskia at gcc dot gnu dot org 2010-04-12 18:20 -------
Well -ffixed-reg-r20 is also broken the same way :) See the duplicated bug
which has a patch which I have not looked into to see if it is the correct fix
yet or not.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (7 preceding siblings ...)
2010-04-12 18:20 ` pinskia at gcc dot gnu dot org
@ 2010-04-15 14:06 ` rguenth at gcc dot gnu dot org
2010-04-15 19:55 ` mikpe at it dot uu dot se
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-15 14:06 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (8 preceding siblings ...)
2010-04-15 14:06 ` rguenth at gcc dot gnu dot org
@ 2010-04-15 19:55 ` mikpe at it dot uu dot se
2010-04-15 22:30 ` mikpe at it dot uu dot se
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mikpe at it dot uu dot se @ 2010-04-15 19:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from mikpe at it dot uu dot se 2010-04-15 19:55 -------
4.3 is also broken. Using the simpler test case in PR43732 and a collection of
cross-compilers to mips-unknown-linux I see:
gcc-4.1.2: -O2 only: ok; -O2 -ffixed-23: ok
gcc-4.2.4: -O2 only: ok; -O2 -ffixed-23: ok
gcc-4.3.x: -O2 only: ok; -O2 -ffixed-23: bug (for x in 0..4)
gcc-4.4.x: -O2 only: bug; -O2 -ffixed-23: bug (x=0, x=3)
gcc-4.5.0: -O2 only: bug; -O2 -ffixed-23: bug
So -ffixed- broke between 4.2 and 4.3, and global register variables broke
between 4.3 and 4.4.
--
mikpe at it dot uu dot se changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpe at it dot uu dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (9 preceding siblings ...)
2010-04-15 19:55 ` mikpe at it dot uu dot se
@ 2010-04-15 22:30 ` mikpe at it dot uu dot se
2010-04-16 13:05 ` mikpe at it dot uu dot se
2010-04-30 8:57 ` jakub at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: mikpe at it dot uu dot se @ 2010-04-15 22:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from mikpe at it dot uu dot se 2010-04-15 22:30 -------
MIPS global register variables worked up to r144963 but broke in r144964:
URL: http://gcc.gnu.org/viewcvs?root=3Dgcc&view=3Drev&rev=3D144964
Log:
2009-03-19 Alexandre Oliva <aoliva@redhat.com>
* reginfo.c (globalize_reg): Recompute derived reg sets.
The corresponding gcc-patches thread started here:
http://gcc.gnu.org/ml/gcc-patches/2009-03/msg00891.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (10 preceding siblings ...)
2010-04-15 22:30 ` mikpe at it dot uu dot se
@ 2010-04-16 13:05 ` mikpe at it dot uu dot se
2010-04-30 8:57 ` jakub at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: mikpe at it dot uu dot se @ 2010-04-16 13:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from mikpe at it dot uu dot se 2010-04-16 13:04 -------
The -ffixed-$reg option worked for MIPS up to r128346 but broke in r128347:
Author: rsandifo
Date: Mon Sep 10 15:21:18 2007
New Revision: 128347
URL: http://gcc.gnu.org/viewcvs?root=3Dgcc&view=3Drev&rev=3D128347
Log:
gcc/
* config/mips/mips.c (mips_global_pointer): Check
call_really_used_regs instead of call_used_regs.
(mips_save_reg_p): Likewise. Save all call-saved registers
if current_function_saves_all_registers. Fix indentation.
No longer treat $18 as a special case.
(compute_frame_size): Guard FPR loop with TARGET_HARD_FLOAT.
See also the thread around:
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg00886.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/43700] [4.4/4.5/4.6 Regression] global register variables defect
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
` (11 preceding siblings ...)
2010-04-16 13:05 ` mikpe at it dot uu dot se
@ 2010-04-30 8:57 ` jakub at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-04-30 8:57 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.4.4 |4.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43700
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-04-30 8:57 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-09 9:31 [Bug c/43700] New: global register variables defect steffenschmidt dot ext at siemens dot com
2010-04-09 9:50 ` [Bug target/43700] " rguenth at gcc dot gnu dot org
2010-04-09 18:13 ` pinskia at gcc dot gnu dot org
2010-04-09 18:21 ` [Bug target/43700] [4.4/4.5/4.6 Regression] " pinskia at gcc dot gnu dot org
2010-04-09 21:52 ` pinskia at gcc dot gnu dot org
2010-04-12 8:41 ` jakub at gcc dot gnu dot org
2010-04-12 9:03 ` mikpe at it dot uu dot se
2010-04-12 18:18 ` pinskia at gcc dot gnu dot org
2010-04-12 18:20 ` pinskia at gcc dot gnu dot org
2010-04-15 14:06 ` rguenth at gcc dot gnu dot org
2010-04-15 19:55 ` mikpe at it dot uu dot se
2010-04-15 22:30 ` mikpe at it dot uu dot se
2010-04-16 13:05 ` mikpe at it dot uu dot se
2010-04-30 8:57 ` jakub at gcc dot gnu dot org
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).