EmbeddedRelated.com
Forums

IAR: May this instruction be optimized out?

Started by reym...@... March 17, 2006
I have noticed a few complaints about IAR from different people but I
haven't heard anyone mention TI's Code Composer Essentials.  Before
you jump
back to command lines and makefiles, take a look at CCE.  I *think* it runs
on linux too...

My .02

On 3/24/06, hlritter <hlritter@hlri...> wrote:
>
>  --- In msp430@msp4..., reymannd@... wrote:
> >
> > Dear all,
> >
> > I've been argueing with IAR's support for some time about
this.
> > Since we could not a conclusion yet, I'd like to hear your
optinion.
> >
> > The statement is
> >
> > *(int*)__segment_begin("DATA16_N") = 0;
> >
> > There s a certain constallation where the compiler entirely throws
this
> > instruction away.  (No, it's not dead code.)
> >
> > In my opinion this is illegal according to the language as the
compiler
> > cannot judge whether this is superfluous or not.
> >
> > Literally the statement for the compiler is:
> > "There's a symbol which you don't know, but the linker
does!  So please
> > write zero to the adress of that symbol!"
> >
> >
> > regards
> > Dirk
> >
>
>
> Hi,
>
> Where I work we use the MSP430 quite a bit and use IAR exclusively.
> Our experience is to just turn all optimization off. IAR is nutorious
> for optimizing out code that is actually used. My opinion of the IAR
> tools is not very high for other reasons also. The people at IAR are
> quite proud of their work and will defend it fiercly even when they
> know they have a problem.
>
> I must admit that having an editor that will format and place the
> cursor for braces is great for productivity. Its also very nice to
> have different parts of the code in colors. It lets the eye and the
> mind quickly identify the various aspects of the code.
>
> I am an old DOS head and worked many years from the command line. I
> did not cross over to Wiondows until Win98. I must admit that a GUI
> that will do most of the grunt work for you is nice. It allows you to
> concentrate on the task at hand, coding, instead of being tied up
> creating the build files. I would not want to regress but
> unfortunately that is what we will probobly do. It appears that we
> will be crossing over to Linux.
>
>
>
>
>
>
>
>
>  .
>
>
>
>
>
>  SPONSORED LINKS
>   Computer internet
security<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+security&w1=Computer+internet+security&w2=Computer+internet+business&w3=Computer+internet+access&w4=Computer+internet+privacy+securities&w5=Computer+internet+help&w6=Texas+instruments&c=6&s7&.signZ9Q_Is69flQPlZteuKw>
 Computer
> internet
business<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+business&w1=Computer+internet+security&w2=Computer+internet+business&w3=Computer+internet+access&w4=Computer+internet+privacy+securities&w5=Computer+internet+help&w6=Texas+instruments&c=6&s7&.sigfdp5NCwqBwePK_awOIw>
 Computer
> internet
access<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+access&w1=Computer+internet+security&w2=Computer+internet+business&w3=Computer+internet+access&w4=Computer+internet+privacy+securities&w5=Computer+internet+help&w6=Texas+instruments&c=6&s7&.sig=t6iyjywM5f5bjjKjklY_ww>
  Computer
> internet privacy
securities<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+privacy+securities&w1=Computer+internet+security&w2=Computer+internet+business&w3=Computer+internet+access&w4=Computer+internet+privacy+securities&w5=Computer+internet+help&w6=Texas+instruments&c=6&s7&.sig=xb9tvshl1Ao9LtZ0o8L1YA>
 Computer
> internet
help<http://groups.yahoo.com/gads?t=ms&k=Computer+internet+help&w1=Computer+internet+security&w2=Computer+internet+business&w3=Computer+internet+access&w4=Computer+internet+privacy+securities&w5=Computer+internet+help&w6=Texas+instruments&c=6&s7&.sigPICQLeaOhPQoHIN4-hKZA>
 Texas
>
instruments<http://groups.yahoo.com/gads?t=ms&k=Texas+instruments&w1=Computer+internet+security&w2=Computer+internet+business&w3=Computer+internet+access&w4=Computer+internet+privacy+securities&w5=Computer+internet+help&w6=Texas+instruments&c=6&s7&.sigw78vr_uEHnPw8wLyZbA>
>  ------------------------------
> >.
>
>
>  ------------------------------
>





Beginning Microcontrollers with the MSP430

Hi, 

> I have noticed a few complaints about IAR from
different 
> people but I haven't heard anyone mention TI's Code Composer 
> Essentials.  Before you jump back to command lines and 
> makefiles, take a look at CCE.  I *think* it runs on linux too...

Eclipse does.  CCE doesn't.

--
Paul Curtis, Rowley Associates Ltd   http://www.rowley.co.uk 
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors


--- In msp430@msp4..., Jonathan Kirwan <jkirwan@...> wrote:

> DATA16_N is C's uninitialized variable
region.  In C, this means it is
> actually initialized to semantic 0's before reaching main().  

These two statements are a contradiction.  If you depend on your C
compiler zeroing your (non-static) global data, you will have
portability issues.  

The only data that "is actually initialized to semantic 0's before
reaching main()" are statically declared data, or explicitly
initialized global data.

Uninitialized, means, uninitialized.




Hi, 

> --- In msp430@msp4..., Jonathan Kirwan
<jkirwan@...> wrote:
> 
> > DATA16_N is C's uninitialized variable region.  In C, this 
> means it is 
> > actually initialized to semantic 0's before reaching main().
> 
> These two statements are a contradiction.  If you depend on 
> your C compiler zeroing your (non-static) global data, you 
> will have portability issues.  
> 
> The only data that "is actually initialized to semantic 0's 
> before reaching main()" are statically declared data, or 
> explicitly initialized global data.

In this case, uninitialized means a declaration without initializer
which has come to be called uninitialized data in common parlance.
Initialized data are those that have initializers.  Global uninitialized
data is initialized to zero before main.  This is all confusing, I know.

--
Paul Curtis, Rowley Associates Ltd   http://www.rowley.co.uk 
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors



On Thu, 30 Mar 2006 14:51:19 -0000, you wrote:

>--- In msp430@msp4..., Jonathan Kirwan
<jkirwan@...> wrote:
>
>> DATA16_N is C's uninitialized variable region.  In C, this means
it is
>> actually initialized to semantic 0's before reaching main().  
>
>These two statements are a contradiction.  If you depend on your C
>compiler zeroing your (non-static) global data, you will have
>portability issues.  
>
>The only data that "is actually initialized to semantic 0's before
>reaching main()" are statically declared data, or explicitly
>initialized global data.
>
>Uninitialized, means, uninitialized.

I'll put it abruptly -- you don't define the meaning.  It's
simply not
up to you.

There is a semantic meaning for the C language when an initializer is
not specified in the source.  But C also includes within that semantic
meaning that such variables, if of static lifetime (meaning that they
exist throughout the program duration), must be initialized to a
semantic zero.  All programmers using C have a right to expect this
behavior.  It is explicit, not implicit.

This is a semantic meaning that exists within the C language and does
bear upon whether or not a C compiler (which obviously is allowed to
rely upon the C language specifications) may consider uninitialized
data as having a _known_ or an _unknown_ value.  In this case, I would
assume that if your statement occurred at a point where the C compiler
could tell itself that the instance was, in fact, 'zero' then the C
compiler could legitimately optimize out the code that also attempts
to set it to zero.  The C compiler is permitted this decision.

Whether or not that was the reason, in that case, is another question.
But one that Anders may have to answer.  I certainly cannot, but you
might try setting it to something other than zero and see if it still
gets optimized away.  My guess and hope is that it won't be.

So far, all this is within the C semantics of "uninitialized."  Which
is not necessarily the same thing from a linker point of view.  Just
as many other words can carry several distinct semantics to them, so
can the term 'uninitialized.'  The linker doesn't need to know
about
the C compiler initialization code's intent to zero out a block.  As
far as the linker is concerned, that region/block of data really is
uninitialized.  It's the C compiler's problem, including code before
main() to zero it out -- not necessarily the linker's.  Of course,
like most other things the real answer here "depends."  It is also
possible to define regions to the linker that the linker is required
to consider as "init to hard zero constant" (or any other constant
set, I suppose, whether from a given value or a file or elsewhere.)
But that's a matter for the linker.  The primary thing here is what
the C compiler can legitimately _know_.  And I think that may be
settled.

You need to change what you imagine as true.  That's all.  Then it all
makes sense.

Jon