Bug 15482 - can't find a register in class `GENERAL_REGS' while reloading `asm'
Summary: can't find a register in class `GENERAL_REGS' while reloading `asm'
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2004-05-16 22:53 UTC by Paul Brook
Modified: 2018-12-20 15:17 UTC (History)
6 users (show)

See Also:
Host:
Target: arm-none-elf
Build:
Known to work:
Known to fail: 4.4.2, 4.5.0
Last reconfirmed: 2005-12-24 20:44:30


Attachments
powerpc testcase (195 bytes, text/plain)
2004-05-16 22:56 UTC, Paul Brook
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Brook 2004-05-16 22:53:09 UTC
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.
Comment 1 Paul Brook 2004-05-16 22:56:08 UTC
Created attachment 6314 [details]
powerpc testcase
Comment 2 Andrew Pinski 2004-05-16 23:06:04 UTC
Confirmed, it should store the arguments on the stack but for some reason they are not which causes 
the ICE.
Comment 3 Paul Brook 2004-05-16 23:15:42 UTC
Similar failure mode to this: 
http://gcc.gnu.org/ml/gcc-patches/2004-04/msg00427.html 
Comment 4 Dominique d'Humieres 2008-01-11 09:35:55 UTC
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).

Comment 5 Uroš Bizjak 2008-02-12 21:11:24 UTC
(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.
Comment 6 Ramana Radhakrishnan 2010-01-09 23:59:29 UTC
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
Comment 7 Richard Earnshaw 2018-12-20 15:17:24 UTC
This seems to have been fixed in gcc-8.  Whippee!