chipKIT® Development Platform

Inspired by Arduino™

MPIDE Compiler Bug?

Created Sun, 05 Aug 2012 01:50:48 +0000 by chudster


chudster

Sun, 05 Aug 2012 01:50:48 +0000

I receive the following error on compilation of my project:

adctest_8_11_2.cpp: In function 'void IC4_IntHandler()': adctest_8_11_2.cpp:711:3: error: unable to find a register to spill in class 'MD0_REG' adctest_8_11_2.cpp:711:3: error: this is the insn: (insn 193 203 200 10 adctest_8_11_2.cpp:661 (parallel [ (set (reg:SI 14 $14 [orig:308 D.12374 ] [308]) (plus:SI (mult:SI (reg:SI 5 $5 [orig:315 xsample_lsm.277 ] [315]) (reg:SI 5 $5 [orig:315 xsample_lsm.277 ] [315])) (reg:SI 14 $14 [422]))) (clobber (scratch:SI)) (clobber (scratch:SI)) ]) 14 {*mul_acc_si} (expr_list:REG_DEAD (reg:SI 14 $14 [422]) (nil))) adctest_8_11_2.cpp:711: confused by earlier errors, bailing out

This is caused by code compiling integer arithmetic in the code fragment below. The error occurs on uncommenting any of the commented statements.


for(count=0; count < RECORD_SIZE; count++){

  while (TMR2 < OC4RS) {
  }

  SPI2BUF = 0x0000;

  nextconv += CONVCYCLE;
  OC4R = nextconv;
  OC4RS = nextconv + CONVTIME;

  fasty = R[buf][count];
  slowy = IIRE[buf][count];
  R[buf][count] -= (int) E[buf][record][count];

  while (!DataRdySPI2()) {
  };

  xsample = SPI2BUF;

// SumXSquared[buf] += xsample * xsample; // sumx[buf] += xsample; // SumFastXTimesY[buf] += xsample * fasty; // SumFastYSquared[buf] += fasty * fasty; // sumfasty[buf] += fasty;

  //      sumslowy[buf] += slowy;
  //      SumSlowYSquared[buf] += slowy * slowy;

// SumSlowXTimesY[buf] += xsample * slowy;

  E[buf][record][count] = xsample;

  R[buf][count] += (int) xsample;

  IIRE[buf][count] += IIRCoeff * (E[buf][record][count] - IIRE[buf][count]);
}

F[buf][record] = T - L[buf];

IIRF[buf] += IIRCoeff * (F[buf][record] - IIRF[buf]);

RFastNum[buf] = 65536*(RECORD_SIZE*SumFastXTimesY[buf] - sumx[buf]*sumfasty[buf]);
RFastDenom[buf] = (RECORD_SIZE*SumXSquared[buf] - sumx[buf]*sumx[buf])*(RECORD_SIZE*SumFastYSquared[buf] - sumfasty[buf]*sumfasty[buf]);

RSlowNum[buf] = 65536*(RECORD_SIZE*SumSlowXTimesY[buf] - sumx[buf]*sumslowy[buf]);
RSlowDenom[buf] = (RECORD_SIZE*SumXSquared[buf] - sumx[buf]*sumx[buf])*(RECORD_SIZE*SumSlowYSquared[buf] - sumslowy[buf]*sumslowy[buf]);

Interestingly the later complicated math compiles but the earlier, if uncommented does not.

Specifically, if I uncomment the first line: SumXSquared[buf] += xsample * xsample;

It does not compile. Messing around further, if I then comment out the first while loop, it compiles again!

The best info I have found is that this is the same as an old (gcc?) compiler bug perhaps related to optimization.

Can anyone help me to find who is the best to submit this to or to find out if there is a fix in a later compiler version for the MPIDE? It prevents compilation of the project and I am unable to rectify by doing anything sensible.

Chudster


chudster

Sun, 05 Aug 2012 02:18:59 +0000

Should have added that the code is in an interrupt that had to be declared as:

extern "C" {}

in order to compile/ link in case that is relevant.


chudster

Sun, 05 Aug 2012 15:51:59 +0000

Further info.

This compiles as a function but not as an interrupt routine.

That is by declaring:

void IC2IntHandler(void){

It will compile.

but not if:

void __ISR(_INPUT_CAPTURE_2_VECTOR, ipl7) IC2_IntHandler (void){

is used.