[LLVMdev] Target backend not converting char* to struct properly.
Stephen McGruer
stephen.mcgruer at gmail.com
Fri Oct 12 10:43:44 PDT 2012
I'm having trouble getting my backend to properly treat the situation where
a char* is converted into a struct, i.e. something like:
char* pointer_representation = ...;
MyStruct* my_struct = (MyStruct*) pointer_representation;
my_struct->an_int_field = 5;
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.
My test case can be seen at http://pastebin.com/zPTi2GRW. 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?
Thanks,
Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121012/3f314a9b/attachment.html>
More information about the llvm-dev
mailing list