[llvm-commits] [llvm-gcc-4.2] r56740 - in /llvm-gcc-4.2/trunk/gcc: c-common.c cp/ChangeLog.apple testsuite/g++.apple/block-nullblockisa.C testsuite/gcc.apple/block-nullblockisa.c
Bill Wendling
isanbard at gmail.com
Fri Sep 26 17:50:04 PDT 2008
Author: void
Date: Fri Sep 26 19:50:02 2008
New Revision: 56740
URL: http://llvm.org/viewvc/llvm-project?rev=56740&view=rev
Log:
The __block storage data structure should reserve an initial new word set to zero.
Added:
llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nullblockisa.C
llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-nullblockisa.c
Modified:
llvm-gcc-4.2/trunk/gcc/c-common.c
llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple
Modified: llvm-gcc-4.2/trunk/gcc/c-common.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=56740&r1=56739&r2=56740&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.c Fri Sep 26 19:50:02 2008
@@ -6175,9 +6175,11 @@
int int_size = int_cst_value (TYPE_SIZE_UNIT (unsigned_type_node));
int offset;
/* dst->object = [src->object retail]; In thid case 'object' is the field
- of the object passed offset by: void* + int + int + void* + void *
+ of the object passed offset by: void * + void* + int + int + void* + void *
This must match definition of Block_byref structs. */
- offset = GET_MODE_SIZE (Pmode) + int_size + int_size + GET_MODE_SIZE (Pmode) +
+ /* APPLE LOCAL radar 6244520 */
+ offset = GET_MODE_SIZE (Pmode) + GET_MODE_SIZE (Pmode)
+ + int_size + int_size + GET_MODE_SIZE (Pmode) +
GET_MODE_SIZE (Pmode);
dst_obj = build2 (PLUS_EXPR, ptr_type_node, exp,
build_int_cst (NULL_TREE, offset));
Modified: llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple?rev=56740&r1=56739&r2=56740&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/ChangeLog.apple Fri Sep 26 19:50:02 2008
@@ -1,3 +1,16 @@
+2008-09-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6244520
+ * decl.c (new_block_byref_decl): New field added to
+ struct __Block_byref_x.
+ (init_byref_decl): Above field initialized to NULL.
+
+2008-09-25 Fariborz Jahanian <fjahanian at apple.com>
+
+ Radar 6237713
+ * parser.c (cp_parser_block_literal_expr): Parse
+ and set attribute on block literals.
+
2008-09-16 Fariborz Jahanian <fjahanian at apple.com>
Radar 6214617
Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nullblockisa.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-nullblockisa.C?rev=56740&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nullblockisa.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-nullblockisa.C Fri Sep 26 19:50:02 2008
@@ -0,0 +1,60 @@
+/* APPLE LOCAL file radar 6244520 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.6 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define HASISA 1
+
+void check(void *ptr) {
+ struct inner {
+#if HASISA
+ void* isa; // should be zero
+#endif
+ long forwarding;
+ int flags;
+ int size;
+ // long copyhelper not needed
+ // long disposehelper not needed
+ int i; //
+ };
+ struct block_with_blocki {
+ long isa;
+ int flags;
+ int size;
+ long impl;
+ long copyhelper;
+ long destroyhelper;
+ struct inner *blocki;
+ } *block = (struct block_with_blocki *)ptr;
+ // sanity checks
+ if (block->size != sizeof(struct block_with_blocki)) {
+ // layout funny
+ printf("layout is funny, struct size is %d vs runtime size %ld\n",
+ block->size,
+ sizeof(struct block_with_blocki));
+ exit(1);
+ }
+ if (block->blocki->size != sizeof(struct inner)) {
+ printf("inner is funny; sizeof is %ld, runtime says %d\n", sizeof(struct inner),
+ block->blocki->size);
+ exit(1);
+ }
+#if HASISA
+ if (block->blocki->isa != (void*)NULL) {
+ printf("not a NULL __block isa\n");
+ exit(1);
+ }
+#endif
+ return;
+}
+
+int main(int argc, char *argv[]) {
+
+ __block int i;
+
+ check(^{ printf("%d\n", ++i); });
+ return 0;
+}
+
Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-nullblockisa.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-nullblockisa.c?rev=56740&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-nullblockisa.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-nullblockisa.c Fri Sep 26 19:50:02 2008
@@ -0,0 +1,60 @@
+/* APPLE LOCAL file radar 6244520 */
+/* { dg-do run } */
+/* { dg-options "-mmacosx-version-min=10.6 -fblocks" { target *-*-darwin* } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define HASISA 1
+
+void check(void *ptr) {
+ struct inner {
+#if HASISA
+ void* isa; // should be zero
+#endif
+ long forwarding;
+ int flags;
+ int size;
+ // long copyhelper not needed
+ // long disposehelper not needed
+ int i; //
+ };
+ struct block_with_blocki {
+ long isa;
+ int flags;
+ int size;
+ long impl;
+ long copyhelper;
+ long destroyhelper;
+ struct inner *blocki;
+ } *block = (struct block_with_blocki *)ptr;
+ // sanity checks
+ if (block->size != sizeof(struct block_with_blocki)) {
+ // layout funny
+ printf("layout is funny, struct size is %d vs runtime size %ld\n",
+ block->size,
+ sizeof(struct block_with_blocki));
+ exit(1);
+ }
+ if (block->blocki->size != sizeof(struct inner)) {
+ printf("inner is funny; sizeof is %ld, runtime says %d\n", sizeof(struct inner),
+ block->blocki->size);
+ exit(1);
+ }
+#if HASISA
+ if (block->blocki->isa != (void*)NULL) {
+ printf("not a NULL __block isa\n");
+ exit(1);
+ }
+#endif
+ return;
+}
+
+int main(int argc, char *argv[]) {
+
+ __block int i;
+
+ check(^{ printf("%d\n", ++i); });
+ return 0;
+}
+
More information about the llvm-commits
mailing list