[cfe-commits] Patch for Bug 13606

John Criswell criswell at illinois.edu
Tue Aug 14 13:28:37 PDT 2012


On 8/14/12 3:02 PM, Eli Friedman wrote:
> On Tue, Aug 14, 2012 at 12:52 PM, John Criswell <criswell at illinois.edu> wrote:
>> Dear All,
>>
>> Attached is a patch to partially fix the alignment attribute bug in
>> PR#13606:
>>
>> http://llvm.org/bugs/show_bug.cgi?id=13606
>>
>> I say partially because the alignment should really be unsigned, but since
>> CharUnits uses a signed value, it isn't clear to me how to fix the bug
>> properly (i.e., it requires a greater knowledge of clang than I current have
>> time to learn).  That said, permitting alignment up to half the address
>> space should be a significant improvement.
>>
>> If this patch meets your approval, please let me know, and I can commit it
>> (I already have commit access to the LLVM SVN repository).
> Please don't use "long"; use int64_t.  "long" doesn't have a
> consistent size across the platforms we support.

Okay, I fixed that.

>
> Please include a testcase.

Done, although should it have a date in the name, or is the current name 
okay?

Regarding the bug report, should I close it, or should I leave it open 
since it's possible to have problems with alignments greater than half 
the address space?

Thanks for the quick reply.

-- John T.

>
> Otherwise, looks fine.
>
> -Eli

-------------- next part --------------
Index: test/CodeGen/align-global-large.c
===================================================================
--- test/CodeGen/align-global-large.c	(revision 0)
+++ test/CodeGen/align-global-large.c	(revision 0)
@@ -0,0 +1,17 @@
+// RUN: %clang -c %s -o /dev/null
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// PR13606 - Clang crashes with large alignment attribute
+char x[4000] __attribute__((aligned(0x100000)));
+
+int
+main (int argc, char ** argv) {
+  char y[4000] __attribute__((aligned(0x100000)));
+  printf("x is %p\n", x);
+  printf("y is %p\n", y);
+
+  return 0;
+}
+
Index: lib/CodeGen/CGValue.h
===================================================================
--- lib/CodeGen/CGValue.h	(revision 161891)
+++ lib/CodeGen/CGValue.h	(working copy)
@@ -128,7 +128,7 @@
 
   // The alignment to use when accessing this lvalue.  (For vector elements,
   // this is the alignment of the whole vector.)
-  unsigned short Alignment;
+  int64_t Alignment;
 
   // objective-c's ivar
   bool Ivar:1;


More information about the cfe-commits mailing list