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.

CCS/TMS320F28374D: C code Static Inline not working

Part Number: TMS320F28374D


Tool/software: Code Composer Studio

Hi everybody , 

I need for some functions  max speed  , and woudl like to use  Static Inline .

now I m on CCS8 , compiler 18.1  ,  and even using  pragma FUNC_ALWAYS_INLINE    I m not able to get the compiler  do the inlining ,  the assembler is  the same  .  Everytime I see a function call . 

I tried with all level of optimization  and  with or without  the pragma FUNC_ALWAYS_INLINE  ( in attach example of what I see , a function call ) . inline issue in compiling.docx

please what should I check ? 

do you have a small working example  to cross check ?

best regards

Carlo

  • Carlo,

    Colombo Carlo said:
    CCS8 , compiler 18.1 

    This is probably not the issue, but I suggest moving to the latest LTS (long term support) compiler (18.12.0.LTS).

    For inline:

    • Compiler only inlines when there is some optimization enabled 
    • The pragma FUNC_ALWAYS_INLINE overrides the compiler inline decisions and may result in pretty large code(!)
    • the pragma must appear before any declaration or reference to the function 
    • Inlining happens during compilation, and not linking.  The compiler must be able to see the body of the called function in order to insert it.  If the function is in a pre-compiled library it will be in object format, and the compiler won't be able to inline it
    The syntax in C is:
           #pragma FUNC_ALWAYS_INLINE ( func );
    The syntax in C++ is:
          #pragma FUNC_ALWAYS_INLINE;

    Regards,

    Lori

  • Carlo,

    I wanted to see if you have been able to make any progress?

    Regards,
    -Lori
  • HI Lori ,
    sharing code and issue issue offline
    best regards
    Calro
  • Carlo,

    Thank you for the details. As I now understand the problem is when a function is called using a pointer to the function. It is not seen when the function is called directly.

    When the compiler pulls a function inline, it places the code for the function directly in place. In order to do this, it has to know exactly which function to use. This is straight forward when the inlined function is called directly.

    In this case, a pointer-to-the-function is used. This is an indirect call to the function. The compiler attempts to determine the contents of a function pointer, and then change an indirect call to a direct call. However, in most cases in practice, this attempt fails. Once it is determined the compiler does not know the contents of the function pointer, it has no choice but to call the function. Inlining a function always requires knowing exactly which function is called, and that is not the case here.

    Regards
    Lori