Compiling the following code with arm-none-elf-gcc -O2 -fno-apcs-frame gives "can't find a register in class `GENERAL_REGS' while reloading `asm'" void bar(int, int, int, int); int x; int foo (int a1, int a2, int a3) { int b; __asm volatile("mov %0, #0":"=r" (b):: /* Clobber everything except the first 3 argument registers. */ , "r3", "r4", "r5", "r6", "r7" , "r8", "r9", "sl","ip", "lr", "fp"); x = b; bar(a1, a2, a3); } Similar examples can probably be constructed on other targets that pass function args in registers.
Created attachment 6314 [details] powerpc testcase
Confirmed, it should store the arguments on the stack but for some reason they are not which causes the ICE.
Similar failure mode to this: http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00427.html
I see the same problem at any level of optimization I have tried on i686-apple-darwin9 for the test case gcc.target/i386/asm-3.c: [ibook-dhum] f90/bug% /opt/gcc/gcc4.3w/bin/gcc -O0 /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c: In function 'main': /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c:19: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm' /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c:19: error: 'asm' operand has impossible constraints The failure was present for rev. 130218 (see http://gcc.gnu.org/ml/gcc-testresults/2007-11/msg00861.html).
(In reply to comment #4) > I see the same problem at any level of optimization I have tried on > i686-apple-darwin9 for the test case gcc.target/i386/asm-3.c: > > [ibook-dhum] f90/bug% /opt/gcc/gcc4.3w/bin/gcc -O0 > /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c > /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c: In function 'main': > /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c:19: error: can't find > a register in class 'GENERAL_REGS' while reloading 'asm' > /opt/gcc/_gcc_clean/gcc/testsuite/gcc.target/i386/asm-3.c:19: error: 'asm' > operand has impossible constraints > > The failure was present for rev. 130218 (see > http://gcc.gnu.org/ml/gcc-testresults/2007-11/msg00861.html). > This test can't run on 32bit x86 PIC targets due to register starvation. dg-skip-if directive was fixed to include all PIC targets with !nonpic target selector.
void bar(int, int, int, int); Corrected testcase void bar (int, int , int); int x; int foo (int a1, int a2, int a3) { int b; __asm volatile("mov %0, #0":"=r" (b):: "r3", "r4", "r5", "r6", "r7" , "r8", "r9", "sl","ip", "lr", "fp"); x = b; bar(a1, a2, a3); } Reconfirmed with trunk as on today
This seems to have been fixed in gcc-8. Whippee!