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.

Compiler replaces memcpy() calls with loads/stores

Hi,

We are using CCS 5.4 with Compiler version 7.4.4 with the 6678 and eabi(ELF) output format. 

We have a bare-metal application and are trying to replace memcpy() with a custom version.

Looking at the .asm output for functions that call memcpy(), the compiler, in most cases, replaces the call to memcpy() with assembly language loads/stores.  In other cases, the call is replaced with calls to RTS functions such as __c6xabi_strasgi_64plus().  We are not including any RTS libraries in our bare-metal application, so these calls wind up as unresolved references in the link step.  In one instance, our custom function is actually called.

It seems the compiler is being too smart in that it knows what memcpy() is supposed to do and replaces the call with the optimal method for the copy based on the types of the source and destination.  __c6xabi_strasgi_64plus(), for example, does a structure copy.   What we really want is for the compiler to always use our custom memcpy() function and not replace these calls with other code.

Is there some way to tell the compiler to do this?

We have optimizations turned off.

Thanks in advance,

Roger

  • Roger Ricotta said:
    Is there some way to tell the compiler to do this?

    Unfortunately, no.

    Thanks and regards,

    -George

  • Hi,

    You can override the __c6xabi_strasgi_64plus(), and all other EABI helper functions (for instance, __c6xabi_strasgi()), by linking with a routine with the appropriate signature and behaviour.

    The prototype and expected behaviour is described in the C66 EABI (SPRAB89).

          void __c6xabi_strasgi_64plus(int32*, const inst32*, uint32)  { .. your memcpy code }

    Nothing can be done when the compiler substitute in-line copy, but this should not be a problem since this don't require any external library support.