Forum Discussion
Altera_Forum
Honored Contributor
21 years agoThe workaround posted by kerry, matches a suggestion from Stephen O'Reilly at Altera I received via e-mail. Namely use the GCC stack debug option
nios-elf-gcc options -mdebug-stack rest of command >& out and looking for lines in the resulting output with stack_info.saves = 0. This will find routines where the stack frame is omitted. However, omitting the stack frame only causes a problem if the compiler also attempts to save to the parent stack frame using the fp register, in which case stack_info.fp_save will be non-zero. So you really want to look for both conditions. For now, I'm sticking with my AWK script that parses the assembly language output since it seems to be working fine and it runs automatically as part of my builds. The -mdebug_stack output does suggest the root of the problem though. The output for a leaf function with one argument that exhibits the bug shows Registers to save
stack_info.locals = 0 bytes, 0 words
stack_info.fp_save = 4 bytes, 1 words
stack_info.saves = 0 bytes, 0 words
stack_info.args = 24 bytes, 6 words
stack_info.cwp = 64 bytes, 16 words
stack_info.aggregate = 4 bytes, 1 words
TOTAL = 96 bytes, 24 words In other words, GCC thinks it HAS allocated 23 words on the stack (args, cwp and aggregate). It looks like the Nios specific back-end is just omitting the code to allocate the stack frame in this case, rather than telling the GCC front end not to generate it.