[llvm-commits] [llvm-gcc-4.2] r46726 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Thu Feb 7 09:35:30 PST 2008


Hi Devang,

> Use appropriate alignment while handling  packed struct member.

the reason I asked for a testcase is that I thought all objects
created by the IR we generate (whether locals, globals or on the
heap) were supposed to be aligned at least as much as the gcc
alignment.  If so, the fact that we create a packed struct type
(alignment 1) shouldn't make the gcc object alignment info in
expr_align wrong, in fact it should be irrelevant.  My fear is
that your change might only be papering over the problem.

>    bool isVolatile = TREE_THIS_VOLATILE(exp);
>    const Type *Ty = ConvertType(TREE_TYPE(exp));
>    unsigned Alignment = expr_align(exp) / 8;
> +  if (TREE_CODE(exp) == COMPONENT_REF)
> +    if (const StructType *STy =
> +        dyn_cast<StructType>(ConvertType(TREE_TYPE(TREE_OPERAND(exp,
> 0))))) +      if (STy->isPacked())
> +        // Packed struct members use 1 byte alignment
> +        Alignment = 1;
> +    
>    

Best wishes,

Duncan.




More information about the llvm-commits mailing list