Hi,
I am using the TI compiler version 7.4.12 with the following flags set (I removed the include file paths):
-mv6740 --abi=coffabi -O1 -ms1 -g --include_path="***" --float_operations_allowed=all --gcc --define="_DEBUG" --define=omapl137 --display_error_number --issue_remarks --diag_wrap=off --remove_hooks_when_inlining --auto_inline=64 --c_extension=.C
I am compiling a project consisting of several C modules, and I got some problems with a relatively large C module (about 2'700 lines of code).
If I enable the optimisation flag -O2, the compiler generates the wrong code, e.g. in this code snippet:
static unsigned int uiIdxPrec;
// the variable uiIdx comes from the function parameters
...
if (ui_calculating_PLC_move)
{
sppc.pPrecMovWait = p_get_PLC_move_queue_scratchpad();
}
else
{
uiIdxPrec = uiIdx;
sppc.pPrecMovWait = pGetPPrecMW(&uiIdxPrec);
}
{
static int idx_axis_preset;
for (idx_axis_preset = 0; idx_axis_preset < defMaxAxis; idx_axis_preset++)
{
static volatile double my_dbl_aux;
my_dbl_aux = dbl_get_actual_position(idx_axis_preset);
sppc.pPrecMovWait->fPosIdealeFinale[idx_axis_preset] = my_dbl_aux;
my_dbl_aux = 0;
sppc.pPrecMovWait->fVelIdealeFinale[idx_axis_preset] = my_dbl_aux;
}
}
the sppc.pPrecMovWait gets the wrong value, e.g. NULL and the sppc.pPrecMovWait->fPosIdealeFinale[] values are wrong.
BTW, even the uiIdxPrec=uiIdx; is wrong, i.e. the uiIdxPrec doesn't get the correct value
I check the called function and they are correct, but the register the calling routine looks for the result isn't the one used by the called one (eg A0 vs B0) so the code is messed up.
If I set the optimisation flag back to -O1, the code works just fine.
I have the same behaviour on small and big functions in this module.
This modules' code is located in external SDRAM while the called routines with the buggy behaviour are located in both external or internal RAM, this doesn't seem important.
The only difference I found from my standard C modules is that this one contains a function with approx 1'500 lines of code, because of a wide switch(), while normally the function are relatively small.
The same C module works OK when compiled for an old TMS320C32 platform, which is where it has been taken from.
Any suggestions?