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 Optimization Level Issue

Hi,

I am using TMS320F2812 for my project. I encountered an issue while uisng compiler optimization level -03. When calling a function 'exit' with the following implemenation

void exit(Int16 status)       
{
  /*-------------------------------------------------------------------*/
  /* SET C$$EXIT LABEL SO THE DEBUGGER KNOWS WHEN THE C++ PROGRAM HAS  */
  /* COMPLETED.  THIS CAN BE REMOVED IF THE DEBUGGER IS NOT USED.      */
  /*-------------------------------------------------------------------*/
  __asm("        .global C$$EXIT");
  __asm("C$$EXIT: nop");
  for (;;);  /* Spins forever */
}


I observed that some code is getting added at the below function call for -02 and higher optimization levels.

   

    setHex();
    //-------------------------------------------------------------------------
    message("Calling function exit...");
    exit(1);
    //asm("test_label:");


Please find the snapshots in the attachment. Because of the extra code getting added for infinite loop(opcode 6F00) the program hangs there.
Could you please let me know why this code gets instrumented when increasing the compiler oprimization level and is there any work around for thsi issue.
I am using CCS V3.3

Thanks,
Melvin