Bug 79696 - "error: can't find a register in class `BREG' while reloading `asm'" when I try to compile valgrind
Summary: "error: can't find a register in class `BREG' while reloading `asm'" when I t...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 2.1.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-15 14:59 UTC by Sabin Iacob
Modified: 2004-06-16 22:51 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Try to make cpuid less dependent on register allocations (953 bytes, patch)
2004-06-13 14:32 UTC, Tom Hughes
Details
Another go at fixing CPUID (8.14 KB, patch)
2004-06-16 20:23 UTC, Tom Hughes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sabin Iacob 2004-04-15 14:59:45 UTC
Version:           2.1.1 (using KDE KDE 3.2.2)
Installed from:    Gentoo Packages
Compiler:          gcc version 3.3.3 20040217 (Gentoo Linux 3.3.3, propolice-3.3-7) Configured with: /var/tmp/portage/gcc-3.3.3/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,f77,objc,java --enable-threads=posix --enable-long-long --disable-checking --enable-cstdio=stdio --enable-clocale=generic --enable-__cxa_atexit --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --enable-interpreter --enable-java-awt=xlib --with-x --disable-multilib
OS:          Linux

make[4]: Entering directory `/usr/src/valgrind/valgrind-2.1.1/coregrind'
if gcc -DHAVE_CONFIG_H -I. -I. -I..  -I./demangle -I../include -I./x86 -DVG_LIBDIR="\"/usr/local/lib/valgrind"\"   -Winline -Wall -Wshadow -O -fno-omit-frame-pointer -mpreferred-stack-boundary=2 -g -DELFSZ=32  -MT vg_to_ucode.o -MD -MP -MF ".deps/vg_to_ucode.Tpo" \
  -c -o vg_to_ucode.o `test -f 'vg_to_ucode.c' || echo './'`vg_to_ucode.c; \
then mv -f ".deps/vg_to_ucode.Tpo" ".deps/vg_to_ucode.Po"; \
else rm -f ".deps/vg_to_ucode.Tpo"; exit 1; \
fi
vg_to_ucode.c: In function `get_cpu_features':
vg_to_ucode.c:109: error: can't find a register in class `BREG' while reloading `asm'
vg_to_ucode.c:109: error: can't find a register in class `BREG' while reloading `asm'
vg_to_ucode.c:109: error: can't find a register in class `BREG' while reloading `asm'
make[4]: *** [vg_to_ucode.o] Error 1
make[4]: Leaving directory `/usr/src/valgrind/valgrind-2.1.1/coregrind'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/usr/src/valgrind/valgrind-2.1.1/coregrind'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/usr/src/valgrind/valgrind-2.1.1/coregrind'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/valgrind/valgrind-2.1.1'
make: *** [all] Error 2

Tried 2.0.0, 2.1.1 and CVS HEAD, same result...

exotic4 valgrind # uname -a
Linux exotic4 2.6.5-gentoo #1 SMP Wed Apr 14 12:53:53 EEST 2004 i686 AMD Athlon(tm) XP 2200+ AuthenticAMD GNU/Linux

exotic4 valgrind # gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: /var/tmp/portage/gcc-3.3.3/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,f77,objc,java --enable-threads=posix --enable-long-long --disable-checking --enable-cstdio=stdio --enable-clocale=generic --enable-__cxa_atexit --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --enable-interpreter --enable-java-awt=xlib --with-x --disable-multilib
Thread model: posix
gcc version 3.3.3 20040217 (Gentoo Linux 3.3.3, propolice-3.3-7)
Comment 1 Nicholas Nethercote 2004-04-15 17:08:01 UTC
I haven't seen anything like this before.  Looks like a GCC issue rather
than a Valgrind issue.

Comment 2 Tom Hughes 2004-06-13 14:14:33 UTC
It is sort of a GCC issue, but not entirely. The way the cpuid() function in vg_to_ucode.c is written it is relying on being able to use EAX, EBX, ECX and EDX and if the GCC optimiser decides that it can't make all of those available because it needs them for other things then the constraints on the inline assembler will fail with the this error.

In this case it is EBX that wasn't available for some reason, so the constraint on  the ebx variable being bound to a register of class B will be failed. 
Comment 3 Tom Hughes 2004-06-13 14:32:20 UTC
Created attachment 6342 [details]
Try to make cpuid less dependent on register allocations

This patch makes the inline assembler used to probe the CPUID more conservative
so that is less dependent on GCC being able to allocate lots of registers to
it.
Comment 4 Tom Hughes 2004-06-16 20:23:23 UTC
Created attachment 6389 [details]
Another go at fixing CPUID

Trying to inline CPUID is just way too hard due to all the implicit registers
and given that we only use it at startup it's far easier to just to write a
proper assembler routine to do it, so this patch does that and fixes both the
core engine and cachegrind to use the new helper.

Note that you need to rerun autogen.sh and configure after applying this patch.
Comment 5 Tom Hughes 2004-06-16 22:51:50 UTC
Patch committed.