[LLVMdev] alignment issue, getting corrupt double values
Peng Cheng
gm4cheng at gmail.com
Sun Dec 30 10:04:27 PST 2012
I also saw this issue before. Llvm seems have trouble returning general
struct values from functions. One easy workaround is to use packed struct
type.
Hope this helps.
-Peng
On Sunday, December 30, 2012, edA-qa mort-ora-y wrote:
> I'm having an issue where a certain set of types and insert/extractvalue
> are producing the incorrect values. It appears as though extractvalue
> getting my sub-structure is not getting the correct data.
>
> I have these types:
>
> %outer = type { i32, %inner, i1 }
> %inner = type { double, i32 }
>
> The trouble is that when I have a value of type %outer then proceed to
> extract the components of the contained %inner structure I get corrupt
> values. If I don't have the "i1" type in there everything works fine,
> leading me to think it is something to do with alignment. I do the
> extraction with code like this:
>
> %o = call %outer @eval_expr()
> %s = extractvalue %outer %o, 1
> %s1 = extractvalue %inner %s, 0
>
> The %s1 value is not correct (not what was inserted). I think extraction
> is the problem and not insertion: in another version I store the value
> to a global variable and dump the bytes of the structure, which can then
> be properly extracted in C++ code. The value is produced with this code
> (in a separate function):
>
> %s0 = insertvalue %inner undef, double 1.500000e+00, 0
> %s1 = insertvalue %inner %s0, i32 2, 1
> %s2 = insertvalue %outer undef, i32 1, 0
> %s3 = insertvalue %outer %s2, %inner %s1, 1
>
>
> I've attached the full sample code which shows the error and where it
> happens.
>
> --
> edA-qa mort-ora-y
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Sign: Please digitally sign your emails.
> Encrypt: I'm also happy to receive encrypted mail.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121230/be3bdbef/attachment.html>
More information about the llvm-dev
mailing list