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.

  • TI Thinks Resolved

Compiler/TMS320F280049C: Inline functions not called/compiled

Prodigy 450 points

Replies: 11

Views: 367

Part Number: TMS320F280049C

Tool/software: TI C/C++ Compiler

Hi,

I tried calling certain inline functions in included header files from an ISR within main.c. However, these function calls never happen – compiler does not flag any error, program compiles and I can debug the program on DSP. But I see that these inline function calls never happen. Seems like the compiler removes these function calls during compilation; I tried changing the optimization level settings from none to 0 to 2 to 4 but didn’t work. What could be preventing the function calls?

Thanks
Siva

  • Even with --opt_level=off, the functions are not called?  I don't understand how that can happen.  I need a test case which allows me to reproduce that behavior.  For the file main.c, please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click This Resolved My Issue on the best reply to your question
    The CCS Youtube Channel
     has short how-to videos
    The 
    Compiler Wiki answers most common questions
    Track an issue with SDOWP. Enter your bug id in the Search box.

  • In reply to George Mock:

    Hi George,

    Thanks for the reply. I have attached the .pp file generated using CCV v8.0.0.00016 3005.main.pp.txt

    Thanks

    Siva

  • In reply to Siva Mohan:

    Thank you for the preprocessed file.

    What compiler options do you use?  What version of the compiler (not CCS) do you use?

    I built with no optimization, and inspected the generated assembly code for the function main.  Every function called in the C code for main is called in the generated assembly code.  Please name one or two functions that are called in the C source that are not called in the generated assembly source.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click This Resolved My Issue on the best reply to your question
    The CCS Youtube Channel
     has short how-to videos
    The 
    Compiler Wiki answers most common questions
    Track an issue with SDOWP. Enter your bug id in the Search box.

  • In reply to George Mock:

    Hi George,

    The compiler version is v18.1.5.LTS. Please find the compiler options in attached screenshot. Please let me know if you need more information. I have tried different opt levels from off to 0 to 2 to 4 and also varied the speed vs size setting in optimization options. None of this helped. I also added #pragma to always inline the functions fclRampControl and SVGenMF but these two inline function calls do not happen.

    Thanks

     Siva

  • In reply to Siva Mohan:

    Siva Mohan
    I also added #pragma to always inline the functions fclRampControl and SVGenMF but these two inline function calls do not happen.

    When I search through the preprocessed file for calls to these functions, I only see calls that are commented out, such as ...

            //fclRampControl(rc1);
            //SVGenMF(svgenmf1);
    

    Your source code has to explicitly call a function.  If not, the compiler generated code does not call it, and thus there is nothing to inline.

    Siva Mohan
    Please find the compiler options in attached screenshot.

    That is not all the compiler options.  Please copy-n-paste the entire build command from the Console view.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click This Resolved My Issue on the best reply to your question
    The CCS Youtube Channel
     has short how-to videos
    The 
    Compiler Wiki answers most common questions
    Track an issue with SDOWP. Enter your bug id in the Search box.

  • In reply to George Mock:

    George,

    Please find the .pp file with the inline function calls not commented at 2211.main.pp.txt

    Also, the build settings are,


    **** Build of configuration Debug for project TIDA-00915 ****

    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O

    Building file: "C:/ti/c2000/C2000Ware_1_00_06_00/device_support/f28004x/common/source/device.c"
    Invoking: C2000 Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla2 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu0 --opt_for_speed=2 --fp_mode=strict --include_path="C:/Users/a0230211/workspace_v8/TIDA-00915" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/include" --include_path="C:/ti/c2000/C2000Ware_1_00_06_00/driverlib/f28004x/driverlib" --include_path="C:/ti/c2000/C2000Ware_1_00_06_00/device_support/f28004x/common/include" --include_path="C:/Users/a0230211/workspace_v8/SDK Motor Control/libraries/utilities/math_blocks/src/v4.3" --advice:performance=all -g --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number "C:/ti/c2000/C2000Ware_1_00_06_00/device_support/f28004x/common/source/device.c"
    Finished building: "C:/ti/c2000/C2000Ware_1_00_06_00/device_support/f28004x/common/source/device.c"

    Building file: "../main.c"
    Invoking: C2000 Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla2 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu0 --opt_for_speed=2 --fp_mode=strict --include_path="C:/Users/a0230211/workspace_v8/TIDA-00915" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/include" --include_path="C:/ti/c2000/C2000Ware_1_00_06_00/driverlib/f28004x/driverlib" --include_path="C:/ti/c2000/C2000Ware_1_00_06_00/device_support/f28004x/common/include" --include_path="C:/Users/a0230211/workspace_v8/SDK Motor Control/libraries/utilities/math_blocks/src/v4.3" --advice:performance=all -g --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number "../main.c"
    "C:/Users/a0230211/workspace_v8/SDK Motor Control/libraries/utilities/math_blocks/src/v4.3/svgen_mf_siva.h", line 60 (col. 57): advice #2614-D: (Performance) Use --fp_mode=relaxed to enable TMU hardware support for FP division.
    Finished building: "../main.c"

    Building target: "TIDA-00915.out"
    Invoking: C2000 Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla2 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu0 --opt_for_speed=2 --fp_mode=strict --advice:performance=all -g --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number -z -m"TIDA-00915.map" --warn_sections -i"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/include" -i"C:/ti/c2000/C2000Ware_1_00_06_00/device_support/f28004x/common/cmd" --reread_libs --diag_wrap=off --display_error_number --xml_link_info="TIDA-00915_linkInfo.xml" --rom_model -o "TIDA-00915.out" "./device.obj" "./main.obj" "C:/ti/c2000/C2000Ware_1_00_06_00/driverlib/f28004x/driverlib/ccs/Debug/driverlib.lib" -l"C:/ti/ccsv8/tools/compiler/ti-cgt-c2000_18.1.5.LTS/lib/rts2800_fpu32.lib" -l"C:/ti/c2000/C2000Ware_1_00_06_00/device_support/f28004x/common/cmd/28004x_generic_ram_lnk.cmd" -llibc.a
    <Linking>
    warning #10210-D: creating ".stack" section with default size of 0x400; use the -stack option to change the default size
    Finished building target: "TIDA-00915.out"

    Thanks
    Siva

  • In reply to Siva Mohan:

    George,

    Please use this version of .pp file 8272.main.pp.txt

    Thanks
    Siva

  • In reply to Siva Mohan:

    Siva,

    Can you verify the same with using older versions of code gen tools, they are available at

    http://www.ti.com/tool/C2000-CGT

    Alternately, you can try similar thing on any other working project and see if the problem is common regardless of the project.

    rgds,

    ramesh

  • Thank you for once again sending in a test case.

    Siva Mohan
    I tried calling certain inline functions in included header files from an ISR within main.c. However, these function calls never happen

    I continue to be unable to reproduce this behavior.  The compiler build options you show include no optimization.  I built with those same options, but added one more: --src_interlist.  This option tells the compiler to keep the generated assembly file (it is deleted by default), and to add comments which make it easier to understand.  I inspected the generated assembly and found this ...

    ;----------------------------------------------------------------------
    ; 54710 | fclRampControl(rc1);                                                   
    ;----------------------------------------------------------------------
            MOVL      XAR4,#_rc1            ; [CPU_ARAU] |54710| 
    $C$DW$247	.dwtag  DW_TAG_TI_branch
    	.dwattr $C$DW$247, DW_AT_low_pc(0x00)
    	.dwattr $C$DW$247, DW_AT_name("_fclRampControl")
    	.dwattr $C$DW$247, DW_AT_TI_call
    
            LCR       #_fclRampControl      ; [CPU_ALU] |54710| 
            ; call occurs [#_fclRampControl] ; [] |54710| 

    This is what a call to a function looks like.  When I compile with optimization --opt_level=2, then I find this near the end of the file ...

    ;* Inlined function references:
    ;* [0] Interrupt_register
    ;* [1] Interrupt_clearACKGroup
    <many lines deleted>
    ;* [23] EPWM_clearEventTriggerInterruptFlag
    ;* [24] fclRampControl
    ;* [25] SVGenMF
    

    This means you can search on the string "[24]" to find code that started in the function fclRampControl, but is now inlined.  There are many such lines.  They look similar to ...

    ;** 54440	-----------------------    v$5 -= 0.00003F;  // [24]
    ;** 54440	-----------------------    goto g9;  // [24]

    The compiler is generating exactly what is expected.  Do you see the same thing?

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click This Resolved My Issue on the best reply to your question
    The CCS Youtube Channel
     has short how-to videos
    The 
    Compiler Wiki answers most common questions
    Track an issue with SDOWP. Enter your bug id in the Search box.

  • In reply to George Mock:

    Do you see the compiler generated code either calling functions such as fclRampControl, or inlining them?

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click This Resolved My Issue on the best reply to your question
    The CCS Youtube Channel
     has short how-to videos
    The 
    Compiler Wiki answers most common questions
    Track an issue with SDOWP. Enter your bug id in the Search box.

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.