Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 274
 2012 Microchip Technology Inc.
All the functions that main() calls, or may call, are shown below. These have been 
grouped in the orange box in the figure. A function’s inclusion into the call graph does 
not imply the function was actually called, but there is a possibility that the function was 
called. For example, code such as:
int test(int a) {
  if(a)
    foo();
  else
    bar();
}
will list foo() and bar() under test(), as either may be called. If a is always true, 
then the function bar() will never be called even though it appears in the call graph.
In addition to these functions there is information relating to the memory allocated in 
the compiled stack for main(). This memory will be used for auto, temporary and 
parameter variables defined in main(). The only difference between an auto and 
temporary variable is that auto variables are defined by the programmer, and 
temporaries are defined by the compiler, but both behave in the same way.
In the orange box for main() you can see that it defines 10 auto and temporary vari-
able. It defines no parameters (main() never has parameters). There is a total of 24 
references in the assembly code to local objects in main().
Rather than the compiled stack being one memory allocation in one memory space, it 
can have components placed in multiple memory spaces to utilize all available memory 
of the target device. This break down is shown under the memory summary line for 
each function. In this example, it shows that some of the local objects for main() are 
placed in the common memory, but others are placed in bank 0 data RAM.
The Used column indicates how many bytes of memory are used by each section of 
the compiled stack and the Space column indicates in which space that has been 
placed. The Base value indicates the offset that block has in the respective section of 
the compiled stack. For example, the figure tells us main()has 6 bytes of memory allo-
cated at an offset of 4 in the compiled stack section that lives in common memory. It 
also has 4 bytes of memory allocated in bank 0 memory at an offset of 16 in the bank 
0 compiled stack component.
Below the information for main() (outside the orange box) you will see the same infor-
mation repeated for the functions that main() called, i.e., rv(), rvx() and rvy(). 
Indentation is used to indicate the maximum depth that function reaches in the call 
graph. The arrows in the figure highlight this indentation.
After each tree in the call graph, there is an indication of the maximum call (stack) depth 
that might be realized by that tree. This may be used as a guide to the stack usage of 
the program. No definitive value can be given for the program’s total stack usage for 
several reasons:
• Certain parts of the call tree may never be reached, reducing that tree’s stack 
usage.
• The contribution of interrupt (or other) trees to the main() tree cannot be deter-
mined as the point in main’s call tree at which the interrupt (or other function 
invocation) will occur cannot be known;
• The assembler optimizer may have replaced function calls with jumps to 
functions, reducing that tree’s stack usage.
• The assembler’s procedural abstraction optimizations may have added in calls to 
abstracted routines. (Checks are made to ensure this does not exceed the 
maximum stack depth.)