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.

TMS570LS1224: 18.1.4 LTS Call to memcpy are replaced

Part Number: TMS570LS1224

Tool/software:

We are using CCS 10.0.0.00010 with Compiler version 18.1.4 LTS

With reference to the following thread:

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/357438/compiler-replaces-memcpy-calls-with-loads-stores

For compiler version 18.1.4 LTS, please could you confirm:

  • Whether or not the compiler replaces certain calls to memcpy with assembly language loads/stores?
  • Is there a way to instruct the compiler not to replace calls to memcpy?
  • Is there a document which details a list of the different circumstances under which the compiler will determine that it can replace a call to memcpy?
  • Hi Paulo,

    In our debugging i found this:

    The compiler generating above code for memcpy API.

    First it is loading the addresses of destination, source and number of bytes into the R0, R1 and R2 respectively and after that it is calling __aeabi_memcpy4 API for actual data copying.

    And here is the definition for the __aeabi_memcpy4 API:

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Thanks for you reply ...

    Below you can see one very simple example of where the compiler (18.1.4 LTS) has replaced a call to memcpy with assembly language loads/stores:

    For the above the source and destination were as follows:

    static UINT32 UISource[4] = {0x0F0E0D0C, 0x0B0A0908, 0x07060504, 0x03020100};
    static UINT32 UIDest[4] = {0x00FFEEDD, 0xCCBBAA99, 0x88776655, 0x44332211};

    This leaves two questions from my initial post:

    • Is there a way to instruct the compiler not to replace calls to memcpy?
    • Is there a document which details a list of the different circumstances under which the compiler will determine that it can replace a call to memcpy?

  • Is there a way to instruct the compiler not to replace calls to memcpy?

    Unfortunately, no.

    Is there a document which details a list of the different circumstances under which the compiler will determine that it can replace a call to memcpy?

    Please search the TI ARM compiler manual for the sub-chapter titled Inlining Intrinsic Operators.  Note this detail:

    abs and memcpy are implemented as intrinsics

    This means memcpy gets special treatment, even when no optimization is used.  

    Consider supplying your own implementation of memcpy.  Suppose you name it custom_memcpy.  Then it might make sense to add:

    #define memcpy custom_memcpy

    as a way to change existing code that calls memcpy.

    Thanks and regards,

    -George