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

Chris Lattner clattner at apple.com
Fri Mar 2 13:13:04 PST 2012


On Mar 2, 2012, at 12:09 PM, Eli Friedman wrote:

> 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.

Hi Eli,

Is this a vague concern or a specific one?  Even GCC-4.2 has been doing this optimization.  I consider this "fixing a regression compared to GCC", not an innovation in optimization.

-Chris




More information about the cfe-commits mailing list