public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: other/7329: fixed or forbidden register bug (and test case)
@ 2002-12-09 16:12 ehrhardt
  0 siblings, 0 replies; 2+ messages in thread
From: ehrhardt @ 2002-12-09 16:12 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, lupus, nobody

Synopsis: fixed or forbidden register bug (and test case)

State-Changed-From-To: open->closed
State-Changed-By: cae
State-Changed-When: Mon Dec  9 16:12:52 2002
State-Changed-Why:
    The code is wrong. Your are not allowed to globber %ebx or use it
    as an asm operand if compiling PIC code. %ebx is used by the pic code
    itself to address pc relative data. I think a workaround could be
    to do something like this:
    __asm__ __volatile__ ("xchg %edi,%ebx\n\tcpuid\n\txchg %edi,%ebx":...)
    and use edi for the output operand. gcc probably can't detect the
    save and restore of ebx, however, this might still be illegal code.
    
        regards   Christian
    

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7329


^ permalink raw reply	[flat|nested] 2+ messages in thread

* other/7329: fixed or forbidden register bug (and test case)
@ 2002-07-16  8:26 lupus
  0 siblings, 0 replies; 2+ messages in thread
From: lupus @ 2002-07-16  8:26 UTC (permalink / raw)
  To: gcc-gnats, debian-gcc


>Number:         7329
>Category:       other
>Synopsis:       fixed or forbidden register bug (and test case)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 16 08:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Paolo Molaro
>Release:        3.1.1 20020703 (Debian prerelease) (Debian testing/unstable)
>Organization:
Ximian
>Environment:
System: Linux luna 2.4.19-pre5 #1 Tue Apr 2 11:33:31 CEST 2002 i686 unknown unknown GNU/Linux
Architecture: i686

host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: /mnt/data/gcc-3.1/gcc-3.1-3.1.1ds2/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/g++-v3-3.1 --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --enable-clocale=gnu --enable-__cxa_atexit --enable-threads=posix --enable-java-gc=boehm --enable-objc-gc i386-linux

The same happens also with gcc 2.7.2 and gcc 2.95.4:
gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
gcc272 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.7.2.3/specs
gcc version 2.7.2.3

>Description:

As part of the mono project we build a library that
needs to detect the x86 processor features. The provided function
is compiled correctly when building a static library, but the compilation 
fails when building a shared library.
Until the bug is fixed it would be nce to know if there is a different
workaround. Thanks.

>How-To-Repeat:
Save the following code to a file name cp.c and compile enabling PIC:

static int 
cpuid (int id, int* p_eax, int* p_ebx, int* p_ecx, int* p_edx)
{
	__asm__ __volatile__ ("cpuid"
		: "=a" (*p_eax), "=b" (*p_ebx), "=c" (*p_ecx), "=d" (*p_edx)
		: "a" (id));
	return 1;
}

and compile it with:

gcc272 -c -fPIC cp.c
error:
cp.c: In function `cpuid':
cp.c:9: fixed or forbidden register was spilled.
This may be due to a compiler bug or to impossible asm
statements or clauses.

gcc-3.1 -c -fPIC cp.c
error:
cp.c: In function `cpuid':
cp.c:5: can't find a register in class `BREG' while reloading `asm'

gcc-2.95 -c -fPIC cp.c
error:
cp.c: In function `cpuid':
cp.c:7: Invalid `asm' statement:
cp.c:7: fixed or forbidden register 3 (bx) was spilled for class BREG.

>Fix:

Compile without -fPIC and it builds fine. I tryed compiling with different
-O options to no avail.

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-10  0:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-09 16:12 other/7329: fixed or forbidden register bug (and test case) ehrhardt
  -- strict thread matches above, loose matches on Subject: below --
2002-07-16  8:26 lupus

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).