Bug 17280 - -mrelax and -O cause .uses directives in assembler to refer to non-existent local labels
Summary: -mrelax and -O cause .uses directives in assembler to refer to non-existent l...
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-09-02 10:33 UTC by Michael Beach
Modified: 2014-12-21 22:39 UTC (History)
1 user (show)

See Also:
Host:
Target: sh-elf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Beach 2004-09-02 10:33:41 UTC
When invoked with the -mrelax and -O flags, the generated assembler may 
contain .uses directives that refer to non-existent local labels (they have 
been optimized out?). 
 
Viz... 
 
bash-2.05b$ ../new-gnu-tools/install/bin/sh-elf-gcc -mrelax -O -c foo2.c 
/tmp/cc75nvlf.s: Assembler messages: 
/tmp/cc75nvlf.s:13: Warning: .uses does not refer to a local symbol in the same 
section 
 
The test program (foo2.c) used is as follows... 
 
extern void foo(int); 
 
int main() 
{ 
  foo(7); 
} 
 
 
The generated assembler looks like... 
 
       .file   "foo2.c" 
        .text 
        .text 
        .align 1 
        .align 2 
        .global _main 
        .type   _main, @function 
_main: 
        mov.l   r14,@-r15 
        sts.l   pr,@-r15 
        mov     r15,r14 
        mov.l   .L3,r1 
        .uses .L2 
        jsr     @r1 
        mov     #7,r4 
        mov     r14,r15 
        lds.l   @r15+,pr 
        rts 
        mov.l   @r15+,r14 
.L4: 
        .align 2 
.L3: 
        .long   _foo 
        .size   _main, .-_main 
        .ident  "GCC: (GNU) 3.4.1" 
 
Note that the problem goes away if the -mrelax option is removed, or if the 
optimisation level is changed to -O0, -O2 or -O3. 
 
I originally encountered this problem while attempting to do a make check of 
binutils-2.15 for sh-elf. It was reporting an error in 
binutils-2.15/ld/testsuite/ld-sh/sh.exp, while attempting to compile 
binutils-2.15/ld/testsuite/ld-sh/sh2.c. I derived the included test program by 
cutting down sh2.c. 
 
Oh, and sh-elf-gcc was built using the following options... 
 
configure --prefix=/home/michaelb/stuff/new-gnu-tools/install --target=sh-elf 
--enable-languages="c,c++" --with-newlib
Comment 1 Richard Biener 2012-01-11 12:29:11 UTC
Is this still an issue?
Comment 2 Michael Beach 2012-01-13 23:21:53 UTC
It's no longer an issue for me, as I'm not working on a project using sh-elf-gcc any more. I'm unaware of whether this problem occurs in more recent gcc releases or not.
Comment 3 Oleg Endo 2014-12-21 22:37:09 UTC
Author: olegendo
Date: Sun Dec 21 22:36:33 2014
New Revision: 218998

URL: https://gcc.gnu.org/viewcvs?rev=218998&root=gcc&view=rev
Log:
gcc/testsuite/
	PR target/17280
	* gcc.target/sh/torture/pr17280.c: New.

Added:
    trunk/gcc/testsuite/gcc.target/sh/torture/pr17280.c
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 4 Oleg Endo 2014-12-21 22:39:26 UTC
Seems to be working on trunk r218998.  Test case added, closed.