Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/22/07 09:56
Read: times


 
#145995 - That indicates a flaw in your code!
Responding to: ???'s previous message
Ekawahyu Susilo said:
Problem's been solved! I put the compiler's optimization to none, and it works just fine.

No, you haven't solved the problem - you have merely masked its symptoms!

If changing optimisation levels "fixes" a problem, that almost certainly indicates that your code is making some unwarranted assumption - and that assumption fails at the higher optimisation level.

You really need to determine the root cause of this - otherwise it will come back to bite you later!

I don't know why the put such a stupid optimization algorithm that removed part of the code while compiling it.

IAR have been in the compiler business for a long time, and I very much doubt that it is a "stupid optimization".
The whole point of optimisation is precisely to remove code that serves no purpose!
All modern compilers perform such optimisations, so you need to understand what they're doing.
Once you understand what the tools are doing, you can make an informed decision about whether the particular optimisation is worthwhile in your particular circumstances.

But one thing that I don't understand, it seemed to me that everything is translated correctly from C to ASM. So, when and where exactly it does the optimization?

I don't know the IAR tools, but it is not uncommon for the Linker to perform post-compile optimisations - Keil certainly do it, as do Raisonance.



List of 14 messages in thread
TopicAuthorDate
CC2430 Timer1 strange behaviour            01/01/70 00:00      
   How to use the 'Insert Code' button            01/01/70 00:00      
   Ok, I post another in pre-formated one ;-)            01/01/70 00:00      
      Brushless1 & 2            01/01/70 00:00      
         IAR            01/01/70 00:00      
            Linker            01/01/70 00:00      
   limit values            01/01/70 00:00      
      limit values            01/01/70 00:00      
         Why do you suspect the Linker??            01/01/70 00:00      
            Problem solved!            01/01/70 00:00      
               That indicates a flaw in your code!            01/01/70 00:00      
                  Understaning C Compiler Optimisations            01/01/70 00:00      
                  Buggy compilers.            01/01/70 00:00      
                     If you fully understand the issues            01/01/70 00:00      

Back to Subject List