C12056: SP debug info incorrect because of optimization or inline assembler
[DISABLE, INFORMATION, WARNING, ERROR]
Description
The compiler investigates the generated code to detect the current SP value for every instruction. During this process, he detects that two different control flows generate different SP values for a single instruction.
This situation may arise because of different situations:
inline assembler
In inline assembler code, it is legal to have this situation as long as the stack is correct at the end of the inline assembler block.
optimization
Especially because of the common code optimization -Of/-Onf there are situations where this occurs in correct code. It is impossible to generate correct debug info for this optimization in some cases.
The debugger may show local variables and the call chain incorrect for some parts in a function, for which this message occurs. But this message does not mean that the code generated is wrong in any sense.
Previous versions of the compiler did generate this warning in other situations, for which this version generates correct debug info.
Example (for C code):
void f(int);
void g(void);
void h(void);
void main(void) {
f(1); f(2); f(3);
h();
f(1); f(2); f(3);
g();
f(1); f(2);
}
The compiler first detects that "f(1); f(2); f(3);" occurs twice and puts this code separately.
The two code patterns are replaced by a JSR to the new code.
This situation can be thought as the following non C pseudo code (C does not support local functions):
void main(void) {
void tmp0(void) {
f(1); f(2); f(3);
}
tmp0();
h();
tmp0();
g();
f(1); f(2);
}
In a next step, the compiler detects that the code "f(1); f(2);" also occurs twice. So
he generates a second internal function.
void main(void) {
void tmp1(void) {
f(1); f(2);
}
void tmp0(void) {
tmp1(); f(3);
}
tmp0();
h();
tmp0();
g();
tmp1();
}
Now the new code of the function tmp1 (actually tmp1 is not really a function, it is a part of main!) is called once directly from main and once indirectly by using tmp0. This two call chains now use a different amount of stack and the message
"C12056: SP debug info incorrect because of optimization or inline assembler"
is issued.
|