[LLVMdev] StructLayout

罗勇刚(Yonggang Luo) luoyonggang at gmail.com
Tue Sep 22 18:47:23 PDT 2009


I have a question. If the size of long is 8 on your x64 platform.
Because the size of long is so different on different platform, sad it
is.

2009/9/23, David Greene <dag at cray.com>:
> How are bitfields handled in StructLayout?  In LLVM 2.5 the
> struct is unambiguously size by:
>
>     StructSize += TD.getTypePaddedSize(Ty); // Consume space for this data
>
> In LLVM 2.6 it's getTypeAllocSize, which does the same thing.
>
> Unfortunately, this is not correct for bitfields.  For example,
> LLVM reports this struct:
>
> typedef struct test1 {
> 	short f0 :  10;
> 	char f1 :  5;
> 	long f2 :  1;
> 	long f3 :  45;
> } test1_t;
>
> which in LLVM is:
>
> %test1 = type { i10, i5, i1, i45 }
>
> to have size 12 on x86-64 whien it should have size 8.
>
> I don't know how to work around this since the original bitfield type has
> been
> lost by the time we translate to LLVM.
>
> Does this need to be handled in the frontend, to munge the struct type
> and add the necessary masking and shifting so it works correctly?
>
> What does llvm-gcc do with something like this?
>
>                                    -Dave
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-- 
从我的移动设备发送

         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo




More information about the llvm-dev mailing list