On Thu, Jun 9, 2016 at 2:22 PM, William Mills wmills@ti.com wrote:
When the optimizer is turned on valgrind complains about writes beyond the current stack pointer. With the optimizer off, the problem report goes away.
000102f8 <main>: 102f8: e3500001 cmp r0, #1 102fc: da000014 ble 10354 <main+0x5c> 10300: e16d41f8 strd r4, [sp, #-24]! ; 0xffffffe8 ^^^^^^^^ Complaint is here
This optimization is called shrink-wrapping. It involves moving the function prologue/epilogue inside an outer-most if statement, so that we we can avoid allocating a stack frame when we don't need it. It can be disabled with -fno-shrink-wrap. Perhaps valgrind has special support to detect stack writes inside a prologue, and this support is failing when a function is shrink wrapped because it can't identify where the prologue is.
Jim