http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55377



Andrew Pinski <pinskia at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

             Status|UNCONFIRMED                 |RESOLVED

         Resolution|                            |INVALID



--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-11-19 
04:36:36 UTC ---

This looks correct as the only thing as:

  while (!serial.canWrite()) {}



cannot change its state once in that loop as far as I can tell.  There are no

volatile variables read either.



canWrite is inlined which was:

 bool canWrite() {

  return !(_txPointers.full(sizeof(TXBuffer)));

 }



And we decided mhvlib::RingBuffer::full only reads from its arguments which are

not volatile.



full does:

 bool full(uint8_t blockLength) {

  return length() > (_size - 1 - blockLength);

 }



Where length was:



 uint8_t length() {

  int16_t length = _head - _tail;

  if (length < 0) {



   length = (_size - _tail) + _head + 1;

  }



  return (uint8_t) length;

 }



And both _head and _tail are not marked as volatile so we only need to read

them once (including through the loop).



So the code that ipa-pure-const is producing is correct.

The reason why you can't produce a simpler testcase is because it depends on

other optimization chooses that the compiler has decided to take.  



So in conclusion, I think you are missing some variables marked as volatile in

the RingBuffer implementation and/or Device_TXImplementation implementation.

Reply via email to