public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/26687] New: gcc -O1 -fno-pic generates bad code that references uninitialized r31
@ 2006-03-15 6:36 bardwell at curl dot com
2006-03-15 9:57 ` [Bug target/26687] " rguenth at gcc dot gnu dot org
2006-03-15 12:33 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: bardwell at curl dot com @ 2006-03-15 6:36 UTC (permalink / raw)
To: gcc-bugs
Overview Description:
gcc 3.3 or gcc 4.0 on Apple's OSX 10.4 generates bad code that references r31
when called with -O1 -fno-pic. If you use -O0 or do not use -fno-pic the
problem.
Steps to Reproduce:
run gcc -O1 -fno-pic -c or gcc-4.0 -O1 -fno-pic -c on:
void broken(double *ret, int num)
{
ret[0] = num ? 0.1 : 0.0;
}
Actual Results:
Compile this source file with "gcc-4.0 -c -O1 -fno-pic".
View the object file with "otool -lrtvdI -s __TEXT __literal8":
[...]
Relocation information (__TEXT,__text) 8 entries
address pcrel length extern type scattered symbolnum/value
00000014 False long n/a LO16 True 0x00000030
False long False PAIR False half = 0x0000
00000010 False long n/a HA16 True 0x00000030
False long False PAIR False half = 0x0034
0000000c False long False LO16 False 2 (__TEXT,__literal8)
False long False PAIR False half = 0x0000
00000008 False long False HA16 False 2 (__TEXT,__literal8)
False long False PAIR False half = 0x0030
(__TEXT,__text) section
_broken:
00000000 cmpwi cr7,r4,0x0
00000004 beq+ cr7,0x1c
00000008 lis r2,0x0
0000000c lwz r9,0x30(r2)
00000010 addis r10,r31,0x0
00000014 lwz r10,0x34(r10)
00000018 b 0x24
0000001c li r9,0x0
00000020 li r10,0x0
00000024 stw r9,0x0(r3)
00000028 stw r10,0x4(r3)
0000002c blr
Contents of (__TEXT,__literal8) section
00000030 0x3fb99999 0x9999999a (1.0000000000000001e-01)
Observe that "r31" is being used without being initialized.
Expected Results:
It should not reference r31 unless it has initialized it...
And if you compile this source file with "gcc-4.0 -c -O1".
View the object file with "otool -lrtvdI -s __TEXT __literal8":
[...]
Relocation information (__TEXT,__text) 8 entries
address pcrel length extern type scattered symbolnum/value
00000024 False long n/a LO16DIF True 0x00000040
False long n/a PAIR True 0x00000008 other_half = 0x0000
00000020 False long n/a HA16DIF True 0x00000040
False long n/a PAIR True 0x00000008 other_half = 0x003c
0000001c False long n/a LO16DIF True 0x00000040
False long n/a PAIR True 0x00000008 other_half = 0x0000
00000018 False long n/a HA16DIF True 0x00000040
False long n/a PAIR True 0x00000008 other_half = 0x0038
(__TEXT,__text) section
_broken:
00000000 mfspr r0,lr
00000004 bcl 20,31,0x8
00000008 mfspr r8,lr
0000000c mtspr lr,r0
00000010 cmpwi cr7,r4,0x0
00000014 beq+ cr7,0x2c
00000018 addis r2,r8,0x0
0000001c lwz r9,0x38(r2)
00000020 addis r10,r8,0x0
00000024 lwz r10,0x3c(r10)
00000028 b 0x34
0000002c li r9,0x0
00000030 li r10,0x0
00000034 stw r9,0x0(r3)
00000038 stw r10,0x4(r3)
0000003c blr
Contents of (__TEXT,__literal8) section
00000040 0x3fb99999 0x9999999a (1.0000000000000001e-01)
Observe that the code seems reasonable.
--
Summary: gcc -O1 -fno-pic generates bad code that references
uninitialized r31
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bardwell at curl dot com
GCC host triplet: gcc version 4.0.0 20041026 (Apple Computer, Inc. build
4061), OS
GCC target triplet: gcc version 4.0.0 20041026 (Apple Computer, Inc. build
4061), OS
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26687
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/26687] gcc -O1 -fno-pic generates bad code that references uninitialized r31
2006-03-15 6:36 [Bug c/26687] New: gcc -O1 -fno-pic generates bad code that references uninitialized r31 bardwell at curl dot com
@ 2006-03-15 9:57 ` rguenth at gcc dot gnu dot org
2006-03-15 12:33 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-03-15 9:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2006-03-15 09:57 -------
with powerpc-unknown-linux and 4.1.0 I get (-O1 -fno-pic -mbss-plt)
broken:
cmpwi 7,4,0
beq 7,.L2
lis 9,.LC0@ha
lfd 0,.LC0@l(9)
b .L4
.L2:
lis 9,.LC1@ha
lfd 0,.LC1@l(9)
.L4:
stfd 0,0(3)
blr
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |target
GCC host triplet|gcc version 4.0.0 20041026 |
|(Apple Computer, Inc. build |
|4061), OS |
GCC target triplet|gcc version 4.0.0 20041026 |powerpc-apple-darwin
|(Apple Computer, Inc. build |
|4061), OS |
Keywords| |wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26687
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/26687] gcc -O1 -fno-pic generates bad code that references uninitialized r31
2006-03-15 6:36 [Bug c/26687] New: gcc -O1 -fno-pic generates bad code that references uninitialized r31 bardwell at curl dot com
2006-03-15 9:57 ` [Bug target/26687] " rguenth at gcc dot gnu dot org
@ 2006-03-15 12:33 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-15 12:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-03-15 12:33 -------
This comes from the following pattern:
(define_insn "movdf_low_si"
[(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
(mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
(match_operand 2 "" ""))))]
"TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_64BIT"
But this has been fixed in 4.1.0 by:
2005-10-08 Andrew Pinski <pinskia@physics.uc.edu>
PR target/24136
* config/rs6000/darwin.md (movdf_low_si): Remove early clobber.
Rewrite for no need for the early clobber.
2005-09-13 Andrew Pinski <pinskia@physics.uc.edu>
* config/rs6000/darwin.md (movdf_low_si): Mark the outgoing r
constraint
as early clobber. Rewrite so the PIC register is not implicitly used.
I rewrote this part so that there was no need for the PIC register.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |normal
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26687
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-03-15 12:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-15 6:36 [Bug c/26687] New: gcc -O1 -fno-pic generates bad code that references uninitialized r31 bardwell at curl dot com
2006-03-15 9:57 ` [Bug target/26687] " rguenth at gcc dot gnu dot org
2006-03-15 12:33 ` pinskia 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).