I'm having trouble getting my backend to properly treat the situation where a char* is converted into a struct, i.e. something like:<div><br></div><div>char* pointer_representation = ...;</div><div>MyStruct* my_struct = (MyStruct*) pointer_representation;</div>
<div>my_struct->an_int_field = 5;</div><div><br></div><div>When this occurs, LLVM seems to fold the struct and char* into one assembly 'object', which is perfectly fine. However, it also keeps the 1-alignment of the char array, which is not ok, as then the assignment (store) to the 'an_int_field' gets converted into a 4-byte aligned store instruction - which of course fails when run. </div>
<div><br></div><div>My test case can be seen at <a href="http://pastebin.com/zPTi2GRW">http://pastebin.com/zPTi2GRW</a>. Does anyone know what I might need to do in my backend to make this work properly - perhaps correct the definition of my 'store' instructions, or set a data-layout for a struct type somewhere?<br>
<br>Thanks,<br>Stephen</div>