Bug 44018 - [4.5/4.6 Regression] Using cpuid.h, can't find a register in class 'CLOBBERED_REGS' while reloading 'asm'
Summary: [4.5/4.6 Regression] Using cpuid.h, can't find a register in class 'CLOBBERED...
Status: RESOLVED DUPLICATE of bug 44174
Alias: None
Product: gcc
Classification: Unclassified
Component: inline-asm (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 4.5.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-06 22:52 UTC by Jack Lloyd
Modified: 2010-07-25 01:49 UTC (History)
5 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2010-05-07 13:08:33


Attachments
Testcase (399 bytes, text/plain)
2010-05-06 22:53 UTC, Jack Lloyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Lloyd 2010-05-06 22:52:54 UTC
I have some code (will be attached) that fails to compile with GCC 4.5.0 if you use the exact right (wrong) flags:

$ g++-4.5.0 -fPIC -m32 -O2 -c cpuid.cpp -o cpuid.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h: In function 'unsigned int get_x86_cache_line_size()':
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: can't find a register in class 'CLOBBERED_REGS' while reloading 'asm'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: 'asm' operand has impossible constraints
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: 'asm' operand has impossible constraints
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: 'asm' operand has impossible constraints

If not using -fPIC, or if using -O instead of -O2, it compiles. This code compiles with the same flags (and any other permutation I've thought to try) with GCC 4.3.1 and 4.4.3. As far as I know the code is valid. I've pruned it down as much as I could.

$ g++-4.5.0 -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/portage/sys-devel/gcc-4.5.0/work/gcc-4.5.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-lto --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/python --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.0 p1.0'
Thread model: posix
gcc version 4.5.0 (Gentoo 4.5.0 p1.0) 

This is the Gentoo build of GCC 4.5.0, but I've checked the packaging; there are no noticeable patches being applied to the 4.5.0 sources, so I think this is a problem in vanilla 4.5.0.
Comment 1 Jack Lloyd 2010-05-06 22:53:46 UTC
Created attachment 20591 [details]
Testcase
Comment 2 H.J. Lu 2010-05-07 00:29:44 UTC
It is triggered by revision 147395:

http://gcc.gnu.org/ml/gcc-cvs/2009-05/msg00369.html
Comment 3 Richard Biener 2010-05-07 10:11:28 UTC
Well, it probably failed before with -funroll-loops.  Why's the cpuid functions
not marked with noinline?
Comment 4 Uroš Bizjak 2010-05-07 12:19:46 UTC
(In reply to comment #3)
> Well, it probably failed before with -funroll-loops.  Why's the cpuid functions
> not marked with noinline?

Because it is only one instruction?

Comment 5 H.J. Lu 2010-05-07 13:08:33 UTC
For some reason, when I change it to C, it compiles.
Comment 6 Jakub Jelinek 2010-05-26 10:03:53 UTC
Perhaps related to PR44174.
Comment 7 Andrew Pinski 2010-07-25 01:49:49 UTC
(In reply to comment #6)
> Perhaps related to PR44174.

Not just perhaps but exactly the same both have the same constraints.


Note this testcase here works now on the trunk but that could have been because of other changes.

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