<div class="gmail_quote">On Tue, Aug 21, 2012 at 3:51 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On Aug 21, 2012, at 3:19 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> SmallVector currently always has 16-byte alignment (on x86_64), no matter what type is contained with it, because SmallVectorBase has a long double member.  This causes problems: for instance, ExtractValueInst has 16 byte alignment due to its Indices member (of type SmallVector<unsigned, 4>), but is only allocated with 8 byte alignment.<br>

><br>
> The attached patch fixes this by removing the long double union hack from SmallVectorBase. Instead, SmallVector's inline storage is represented as a sequence of  llvm::AlignedCharArrayUnion<T> objects, with the first such object living in SmallVectorTemplateCommon<T> rather than in SmallVectorBase.<br>

><br>
> The downside of this is that SmallVector<T> now always requires T to be a complete type. However, it turns out that no code in LLVM or Clang was deliberately depending on SmallVector<T, 0>'s promise that T is not required to be complete. This did however expose a problem: ArrayRef<T> copy-construction was implicitly instantiating SmallVectorTemplateCommon<T> (and std::vector<T>) during overload resolution. To avoid this, I've added a dummy template parameter to SmallVectorTemplateCommon, so now the ArrayRef(SmallVector) constructor will only be considered if the argument is already of type SmallVector (and not merely if it converts to a SmallVector). I've applied the same change to the ArrayRef(std::vector) constructor, where the same problem exists, but our current standard library implementations happen to allow us to get away with it.<br>

<br>
</div></div>LGTM, thanks!<br></blockquote><div><br></div><div>Thanks, r162331.<br></div></div>