Bug 14090 - inline asm statement only compiles with -O
Summary: inline asm statement only compiles with -O
Status: RESOLVED DUPLICATE of bug 11203
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-10 00:17 UTC by Westlely Weimer
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Westlely Weimer 2004-02-10 00:17:17 UTC
The following 18-line program (adapted from the linux 2.4.24 scheduler) compiles
with "gcc -c -O min.c" but does not compile with "gcc -c min.c" on x86/linux. It
is my belief that -O should not change the set of acceptable programs. It seems
unlikely that you'll be able to "fix" this, but I think it at least worth
documenting (in the reported error message itself, if possible). Thanks!

/* begin: min.c */
struct thread_struct {
   unsigned long eip ;
   unsigned long esp ;
};
struct task_struct {
   struct thread_struct thread ;
};
void ( __attribute__((__regparm__(0))) schedule)(void) 
{ struct schedule_data *sched_data ;
  struct task_struct *prev ;
  struct task_struct *next ;
    __asm__  volatile ("nop": 
                       "=m" (prev->thread.esp), 
                       "=m" (prev->thread.eip),
                       "=b" (prev): 
                       "m" (next->thread.esp), "m" (next->thread.eip),
                       "a" (prev), "d" (next), "b" (prev));
}
/* eof: min.c */

Here's a log of it failing to compile without -O on a newly-built gcc 3.3.2, and
then working with -O. Same behavior (slightly different error message: "fixed or
forbidden register 6 (bp) was spilled for class GENERAL_REGS") with gcc 2.95.4. 

afflatus:/scratch/weimer/linux-2.4.24/delta$ /scratch/weimer/gcc/bin/gcc -v -c
min.c    
Reading specs from
/scratch/weimer/gcc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: ./configure --prefix /scratch/weimer/gcc/
Thread model: posix
gcc version 3.3.2
 /scratch/weimer/gcc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.2/cc1 -quiet -v
-iprefix /scratch/weimer/gcc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.2/
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 min.c -quiet -dumpbase
min.c -auxbase min -version -o /tmp/ccQ3IXgq.s
GNU C version 3.3.2 (i686-pc-linux-gnu)
        compiled by GNU C version 2.95.4 20011002 (Debian prerelease).
GGC heuristics: --param ggc-min-expand=90 --param ggc-min-heapsize=113214
ignoring nonexistent directory "/scratch/weimer/gcc/i686-pc-linux-gnu/include"
ignoring nonexistent directory "/scratch/weimer/gcc/i686-pc-linux-gnu/include"
ignoring duplicate directory
"/scratch/weimer/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /scratch/weimer/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include
 /usr/local/include
 /scratch/weimer/gcc/include
 /usr/include
End of search list.
min.c: In function `schedule':
min.c:12: error: can't find a register in class `GENERAL_REGS' while reloading `asm'
afflatus:/scratch/weimer/linux-2.4.24/delta$ /scratch/weimer/gcc/bin/gcc -v -c
min.c -O
Reading specs from
/scratch/weimer/gcc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: ./configure --prefix /scratch/weimer/gcc/
Thread model: posix
gcc version 3.3.2
 /scratch/weimer/gcc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.2/cc1 -quiet -v
-iprefix /scratch/weimer/gcc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3.2/
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 min.c -quiet -dumpbase
min.c -auxbase min -O -version -o /tmp/ccgEur4n.s
GNU C version 3.3.2 (i686-pc-linux-gnu)
        compiled by GNU C version 2.95.4 20011002 (Debian prerelease).
GGC heuristics: --param ggc-min-expand=90 --param ggc-min-heapsize=113214
ignoring nonexistent directory "/scratch/weimer/gcc/i686-pc-linux-gnu/include"
ignoring nonexistent directory "/scratch/weimer/gcc/i686-pc-linux-gnu/include"
ignoring duplicate directory
"/scratch/weimer/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /scratch/weimer/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include
 /usr/local/include
 /scratch/weimer/gcc/include
 /usr/include
End of search list.
 as -V -Qy -o min.o /tmp/ccgEur4n.s
GNU assembler version 2.12.90.0.1 (i386-linux) using BFD version 2.12.90.0.1
20020307 Debian/GNU Linux
afflatus:/scratch/weimer/linux-2.4.24/delta$ ls -la min.o
-rw-rw-r--    1 weimer   weimer        584 Feb  9 16:10 min.o
Comment 1 Andrew Pinski 2004-02-10 01:16:33 UTC
This is a dup of bug 11203.

*** This bug has been marked as a duplicate of 11203 ***