Since winIDEA 2011 build 47 iSYSTEM's profiler supports compiler tail merge optimizations.
What is tail call merging (tail-call optimization or tail-call elimination)?
Tail call merging is a compiler optimization used by almost all modern compilers. But many compilers provide options to suppress tail call merging.
Without tail-call merge: When calling a subroutine the caller pushes its return address on the stack and hands control to the subroutine. The very last thing the subroutine does is a pop from stack to read the caller's address and return control to this address.
With tail-call merge: When a subroutine call is the very last command to execute (in the caller's function), it´s save to jump to the start of subroutine directly without adding a stack frame and reusing the caller's stack. When the subroutine is done, it will return it's results directly to the caller.
For more information see Wikipedia/Tail-call
What are the benefits of tail-call merging?
The main benefits of tail-call merging are saving stack space which is very important on recursive function calls and saving execution time which is important for embedded applications where every microsecond might count.
How does tail-call merging affect a profiler?
For the profiler tail-call merging looks like moving the subroutine's A code into the function body of the caller's function B. In Range Mode execution in function B would be attributed to function B, instead of the optimized function A. That would lead to incorrect time measurements in the profiler.
iSYSTEM's winIDEA has now a new option. If in Profiler/Configuration the option "Tail-merge analysis" is enabled, the profiler performs analysis of tail-call merge optimizations on the fly. This analysis ensures correct measurements in the profiler, but requires a higher level of debug information quality and relies on object code analysis.
If the analysis algorithm fails, profiler session aborts. In such case the tail-call merge analysis can be disabled to revert to regular range mode. Another solution is to tell the compiler not to use tail-call merging.
Comments