[Bug rtl-optimization/64010] New: [msp430-elf] struct function dereference clobbers parameter passed to function
amykyta3 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 21 03:08:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64010
Bug ID: 64010
Summary: [msp430-elf] struct function dereference clobbers
parameter passed to function
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: amykyta3 at gmail dot com
Created attachment 34061
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34061&action=edit
msp430-elf src file
Using TI's prepackaged msp430-elf-gcc (version 4.9.1 20140707)
Also verified with most recent build (version 5.0.0 20141121)
When compiling with -O1 or higher, optimization is clobbering the 'dbe' struct
pointer in the snippet below:
--------------------------------------------------------------------
void param_to_string(char *dst_str, uint8_t dst_size, convert_entry_t *dbe){
dbe->to_string(dst_str, dst_size, dbe);
}
--------------------------------------------------------------------
When dereferencing to_string, the original dbe is overwritten and passed into
the to_string function.
Resulting disassembly:
--------------------------------------------------------------------
void param_to_string(char *dst_str, uint8_t dst_size, convert_entry_t *dbe){
dbe->to_string(dst_str, dst_size, dbe);
459c: 1e 4e 02 00 mov 2(r14), r14 ;
000045a0 <.LVL11>:
45a0: 8e 12 call r14 ;
000045a2 <.LVL12>:
}
45a2: 30 41 ret
--------------------------------------------------------------------
Full src file included for more context
More information about the Gcc-bugs
mailing list