NO

Author Topic: Internal compiler error  (Read 5195 times)

ttomek

  • Guest
Internal compiler error
« on: December 01, 2004, 03:18:44 pm »
Hi,

I'm relatively new to Pelles C but already enjoying it.
However, I've encountered an internal error (not very nasty,
'cause there's a simple way of avoiding it) when compiling
quite simple code.

The exact error message is:

c:\ttstor.c(188): fatal error: Internal error: best_spillee

The error points to the following line of code:
r->data = ~ a->data;

where r is a struct, data is its field of type char*, and the mentioned
line is a part of a simple for loop with i as its control variable.
What's interesting is that the error appears only if one sets __fastcall
calling convention in the project options. Both __cdecl and __stdcall
cause no errors.

I'm just reporting it for future consideration, at the same time expressing
my gratitude for such a nice _free_ programming environment.

regards
Tomasz Tyrakowski

p.s. I can send the function or the whole module if neccessary.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2076
    • http://www.smorgasbordet.com
Internal compiler error
« Reply #1 on: December 01, 2004, 06:26:59 pm »
Hello,

Thank you very much - also for the bug report. I have seen this myself a few times (in different contexts).

The basic problem is with the register allocator, and the rather few registers available on X86 targets. The fastcall calling convention will stress the register allocator even further, since the arguments must go into specific registers (ecx and edx).

I would appreciate if you could send me the smallest compilable (in theory) example.

Pelle
/Pelle

ttomek

  • Guest
Internal error best_spillee code sample
« Reply #2 on: December 02, 2004, 11:24:11 am »
Hi,

I'm aware it has to have something to do with register allocation
and I'm very well aware Intel is short of registers :)
Anyway, try to put the snippet below into any .c file and
make a static library out of it.
The error should appear.

best regards
Tomasz Tyrakowski

#define ttBytesInBitArray(A) ((A)->len & 0x00000007 ? ((A)->len>>3) +1 : (A)->len>>3)

typedef struct {
   unsigned char *data;      
   int len;            
   int setbits;         
   int minset;         
   int maxset;         
   int maintain;
} ttBitArray;

void ttBitArrayComplement(ttBitArray *a, ttBitArray *r)
{
   int i, byt;
   if (r->len != a->len) return;
   byt = ttBytesInBitArray(r);
   r->setbits = a->len - a->setbits;
   for (i=0; i<byt; i++) {
      r->data = ~ a->data;
   }
}

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2076
    • http://www.smorgasbordet.com
Internal compiler error
« Reply #3 on: December 02, 2004, 05:25:53 pm »
Thanks! Yes, I get the same error. Will try to fix it...

Pelle
/Pelle

mtx500

  • Guest
another example
« Reply #4 on: December 17, 2004, 02:04:22 pm »
Hi,
I probably got the same error here!

I'm attaching a stripped down example that reproduces the bug. Maybe it helps you find the error more quickly. Also, it provides another test case for you after the fix is done :-)

I used "pocc.exe /O2 example.c" to compile it. It produces:

example.c(14): warning #2115: Local 'LocVar' is initialized but never used.
can't spill register variable: esi (1) pArg2
example.c(16): fatal error: Internal error: best_spillee.

The warning is ok because I removed the usage of LocVar but still needed its calculation for the error to show up.

:::: example.c ::::

typedef struct tagStruct
{
    unsigned int Field1;
    unsigned int Field2;
} tStruct;

void func1 (tStruct * pArg1, double * pArg2)
{
    *pArg2 = (double) pArg1->Field1 + (double) pArg1->Field2;
}

void func2 (tStruct * pArg1, tStruct * pArg2)
{
    char LocVar = pArg1->Field1 && pArg1->Field1;

    pArg2->Field1 = pArg1->Field1 - pArg1->Field1 / 100 + pArg1->Field1 / 400;
    pArg2->Field2 = pArg1->Field2;
}

:::: end ::::

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2076
    • http://www.smorgasbordet.com
Re: another example
« Reply #5 on: December 17, 2004, 07:13:26 pm »
Thank you for the report. Same message but different problem - will try to fix this one too!

Pelle
/Pelle