[llvm-commits] PATCH: clang ext_vector_type alignment in packed structure
Schoedel, Kevin P
kevin.p.schoedel at intel.com
Wed Mar 14 11:06:28 PDT 2012
When an ext_vector_type appears inside a structure, clang's CodeGen
does not supply an alignment on loads and stores. Because of this,
InstCombine subsequently adds an alignment based purely on the type,
which is incorrect in the case that the structure is packed.
For example,
typedef float float4 __attribute__((ext_vector_type(4)));
struct __attribute__((packed, aligned(4))) packed_struct {
unsigned int use_some_space;
float4 position;
};
static float f(struct packed_struct *p)
{
return p->position.x;
}
yields
%1 = load <4 x float>* %position
which after InstCombine becomes
%1 = load <4 x float>* %position, align 16
even though the 'position' member is aligned only to 4 bytes.
The attached patch adds code to CGExpr.cpp to propagate the (estimated)
alignment of the underlying element. Please review and commit if
appropriate.
Thanks,
--
Kevin Schoedel kevin.p.schoedel at intel.com +1-519-772-2580
SSG-DPD-ECDL-DMP - Intel Dynamic Mobility and Parallelism
More information about the llvm-commits
mailing list