In this tutorial, we talk about C/C++ compiler and optimization with ARM processors.
We first briefly talk about ARM architecture and then quickly move into C/C++ compiling and linking technologies and optimizations.
This tutorial has a heavy focus on arm processors which is the most popular processor family in mobile, embedded, and low power domain.
It is a 101 page slides.
The following are some of the topics touched.
What is tail-call optimization to avoid the use of unnecessary returns in function hierarchies?
How to estimate Stack size?
1. Linking with -callgraph produces a static callgraph in html showing information on all functions, including stack usage
2. Set a watchpoint on the last available location in the stack and see if the watchpoint is ever hit (severe performance penalty with ARMulator or Angel).
3. Define a stack which is much larger than you expect you need, then fill it with a known value (e.g. zero or 0xDEADDEAD). Run your application. After your application has finished running, examine the stack area of memory to see how many of the zeros (or 0xDEADDEAD) have been overwritten by stack accesses. This will show how far the stack has grown in memory. You can then adjust the size of the stack to (a little above) this known size.
4. If using ARMulator, use a map file to define a region of memory where access is not allowed (with ‘-‘). Place this region directly below your stack in memory. If the stack overflows into the forbidden region, a data abort will occur, which can be trapped by the Debugger.
5. Can do a similar thing with an MMU or MPU by marking an area as no access.
Concerns in alignment of pointers:
How to optimize base pointer:
Here is the full 101-page slides:
Use points to gain access. You can either purchase points or contribute content and use contribution points to gain access.