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/MSP432P401R: How to force compiler NOT TO inline "ASSEMBLY FUNCTION" ?

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hello,

I am measuring the usage of STACK segment at SRAM.

For the test, a program was designed to have the various number of local variables, such as 10, 100 or 1000.

(My experiment was on MSP432P401R evaluation board using Code Composer Studio v7.)

As the experiments proceeded, however, something strange happened.

That is, the number of local variables affects the assembly code of the program.

If the number of local variables is 10,  LDM or STM assembly codes were used to store on the STACK.

But, as the number of local variables is larger than 100, another function was called.

The name of the function is "__aebi_memcpy(), __aebi_memcpy4(), __aebi_memcpy8(), memcpy() ", specified with '.asmfunc stack_usage(0)' containing PUSH and POP codes.

(All of the assembly codes and function callings were checked on the debugging mode of CCS v7.)

1. I concluded this situation happened because of the optimization of the arm compiler (such as inlining of function).

   Is this a proper guess? or Is there any other reasons for this?

2. If so, I would like to make compiler not to use the function arbitrarily.

   Which means, I would like to make my program use only assembly codes like LDM or STM, not memcpy().

   I already used one of the compiler option named --disable_inlining, but nothing worked.

   Is there any way to do?

Thank you 

  

  • Koo9 said:
     Is there any way to do?

    Probably not.  That said, I don't really understand what you are doing.  Please send in a test case which does this ...

    Koo9 said:

    But, as the number of local variables is larger than 100, another function was called.

    The name of the function is "__aebi_memcpy(), __aebi_memcpy4(), __aebi_memcpy8(), memcpy() ", specified with '.asmfunc stack_usage(0)' containing PUSH and POP codes.

    Please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George

  • Thank you for your reply. Sorry for the confusion.

    The thing that I want to do is,

    I want my programs to use STACK segment exactly same with the same assembly code "regardless of the number of local variables."

    The detail of two attached preprocessed files are followed: 

    1. main_compilertestcase_num10.pp

    - This is a source file of compiler test case with 10 local variables.

    - It consists of main and function1. Function1 is a user defined function, simply executes bubble sorting for 1000 times.

    2. main_compilertestcase_num100.pp

    - This is a source file of compiler test case with 100 local variables.

    - It consists of main and function1. Function1 is a user defined function, simply executes bubble sorting for 1000 times.

    (The number of local variables, 10 and 100, is the only difference of two attached files.)

    In both case, TI v16.9.6.LTS Compiler is used with the compiler options:

    **** Build of configuration Debug for project CompilerTestCase ****

    "C:\\ti\\ccsv7\\utils\\bin\\gmake" -k -j 4 main_compilertetcase.obj -O
    'Building file: ../main_compilertestcase.c'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/Users/ESLAB/workspace_v7/CompilerTestCase_num10" --include_path="C:/ti/simplelink_msp432p4_sdk_1_50_00_12/source" --include_path="C:/ti/simplelink_msp432p4_sdk_1_50_00_12/source/third_party/CMSIS/Include" --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include" --advice:power=none --define=__MSP432P401R__ --define=DeviceFamily_MSP432P401x -g --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --gen_func_subsections=on --disable_inlining "../main_compilertestcase.c"
    'Finished building: ../main_compilertestcase.c'
    ' '

    **** Build Finished ****

    main_compilertestcase_num10_and_num100.zip

  • You want to control how the compiler initializes a large local array.  Unfortunately, there is no method for doing that.  The rest of this post gives further detail.

    The test case with the smaller array has these lines to create and initialize a local array ...

           volatile int array11[10] = {
                        559, 771, 983, 46, 764, 63, 1000, 606, 71, 781
            };

    Let's call this "test10.c".

    The other test case has similar array, but with 100 values.  Let's call it "test100.c".

    In both cases, a table of constant values is placed in memory.  Code at the start of the function copies this table of constants to the location of the array on the stack.  The question is: Exactly how is the copy implemented?  In test10.c, a series of LDM and STM instructions are used.  In test100.c, the RTS function memcpy is called.  You want to tell the compiler, in the case of test100.c, to not call memcpy, but use a series of LDM and STM instructions.  Unfortunately, there is no method for doing that.

    Thanks and regards,

    -George