[cfe-commits] [PATCH] PR12094: set alignment of memory builtins

Eli Friedman eli.friedman at gmail.com
Fri Mar 2 12:09:30 PST 2012


On Fri, Mar 2, 2012 at 3:57 AM, Jay Foad <jay.foad at gmail.com> wrote:
> http://llvm.org/bugs/show_bug.cgi?id=12094
>
> The attached patch:
>
> - Makes CGBuiltin.cpp's helper function GetPointeeAlignment into a
> proper member of CodeGenFunction and splits it into two:
> -- GetPointeeAlignment, which returns alignment as an unsigned, and
> -- GetPointeeAlignmentValue, which wraps the result in an llvm::Value
> for the convenience of generating ARM NEON intrinsics.
>
> - Uses GetPointeeAlignment to set a sensible alignment on all memory
> intrinsics (memcpy, memset etc.) instead of the conservative default
> of 1.

I don't think this is really safe; strictly speaking, yes, an int* is
required to be appropriately aligned, but in practice neither clang
nor gcc has ever tried to enforce that, so making that assumption is
going to cause trouble.

-Eli



More information about the cfe-commits mailing list