This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/14090] New: inline asm statement only compiles with -O
- From: "weimer at cs dot berkeley dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Feb 2004 00:17:28 -0000
- Subject: [Bug c/14090] New: inline asm statement only compiles with -O
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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
--
Summary: inline asm statement only compiles with -O
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: weimer at cs dot berkeley dot edu
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14090