[Bug rtl-optimization/64010] New: [msp430-elf] struct function dereference clobbers parameter passed to function

2014-11-20 Thread amykyta3 at gmail dot com
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 mov2(r14),r14;

45a0 <.LVL11>:
45a0:8e 12   callr14;

45a2 <.LVL12>:
}
45a2:30 41   ret


Full src file included for more context


[Bug rtl-optimization/64010] [msp430-elf] struct function dereference clobbers parameter passed to function

2014-12-02 Thread amykyta3 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64010

--- Comment #8 from Alex Mykyta  ---
Also confirmed Ulrich's patch.
Thank you for taking care of this.