> The parameters deleted are the globals. > But we are making the code reentrant by passing the parameters to the > function.If the parameters passed are globals then the compiler deletes > that particular parameter and takes from the global which is available. > But we want the code to be reentrant. > If we don't use program level optimization ,parameters don't get deleted > but we don't get better optimization without -pm option.So using the > program level optimization can we overcome this problem. [The following are my comments based on what little I know of your code.] What direct connection do you believe there is between the global variable and making the function reentrant? What sort of re-entrancy are you using? Interrupt driven? Do you just want to make sure that the function copies the value at the beginning of the function and ignores further changes to the global variable while within the function? The compiler, in program mode, can see all the function calls to every function (unless you have assembly, see below). It can tell that every time you call this function, you are using a global variable as a parameter. Therefore, it can avoid the extra time spent pushing and popping the value from the stack at each call, and instead delete the parameter and just copy the global variable once inside the function. This has nothing direct to do with re-entrancy. If the global variable is changed and the function called a second time, the function will again make a copy of the data once it begins the second time (or at least it should). Note that the global variable, if it's possible it can be changed in something like an interrupt, needs to be marked volatile to tell the compiler that it can change without warning in a flow of code that otherwise does not contain modifications to it. Also note that if you have assembly functions which might be calling this function, then you also need to use the pragma FUNC_EXT_CALLED to tell the compiler that there are calls to the function outside of the code that it can see, and so to reduce certain types of optimizations. Otherwise, it all your interrupt handlers are in C and are compiled in when doing program mode optimization, then the compiler seems correct in it's deleting the parameter that it can more easily get from the global variable, and this should not affect reentrancy. -W |