This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

inline function in simulator d'ont work properly

Hi people, I have a problem. I probe a inline function, but the compiler I believe d'ont inlinezed the code.

I just read the spru514f.pdf section 2.10, and properly put the compiler options.

I use the Texas Instruments Simulator.

I want put the inline code in a f28069 or f28335

Any have any idea that ocurrs?

 

  • Guillermo,

    Let's call the function to be inlined the "Child" function, and the function calling it the "Parent" function.  In order to inline the child, the child source code must be in the same source file as the parent source code.  If the child is in a different source file, the compiler will not inline it.  Do you have the child in the same source file as the parent?

    Regards,

    David

  • Hi David, if you can look at the attach file (main.c), can you check the Child and Parent function are in the same file. 

    I estimate your answer, but the problema remain too.

     

    guillermo

  • Guillermo,

    I tried your main.c, and found the function was not inlined.  So I did a quick read of the Compiler user's guide, SPRU514F, section 2.10.  First thing you need to do is turn on -o3 or greater optimization to get inlining.  Even then, per SPRU514F, the compiler can still decide not to inline if it determines it more efficient not to.  I turned on -o3 optimization, and then saw the compiler optimize your example away (it just precomputed everything).   You need to make the vars volatile to keep it from doing this for your simple example (in a regular application, the optimizer likely wouldn't have enough visibility into the vars to optimize things away so you probably wouldn't need to use volatile).

    volatile float volume,radius,i=0;

    If you do the -o3 and add the volatile, the compiler will inline your function in your simple example.

    Regards,

    David

     

  • Ok David, I have put volatile sentence in variables at work properly the optimization.

     

    Thanks David.

     

    guillermo