[cfe-commits] r81423 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGen/blocks-seq.c

Anders Carlsson andersca at mac.com
Wed Sep 9 18:32:12 PDT 2009


Author: andersca
Date: Wed Sep  9 20:32:12 2009
New Revision: 81423

URL: http://llvm.org/viewvc/llvm-project?rev=81423&view=rev
Log:
Make the forwarding member of block byref structs be a pointer to the block byref struct itself.

Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/test/CodeGen/blocks-seq.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=81423&r1=81422&r2=81423&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Sep  9 20:32:12 2009
@@ -223,8 +223,11 @@
   std::vector<const llvm::Type *> Types(needsCopyDispose*2+5);
   const llvm::PointerType *PtrToInt8Ty
     = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
+  
+  llvm::PATypeHolder ByRefTypeHolder = llvm::OpaqueType::get(VMContext);
+  
   Types[0] = PtrToInt8Ty;
-  Types[1] = PtrToInt8Ty;
+  Types[1] = llvm::PointerType::getUnqual(ByRefTypeHolder);
   Types[2] = llvm::Type::getInt32Ty(VMContext);
   Types[3] = llvm::Type::getInt32Ty(VMContext);
   if (needsCopyDispose) {
@@ -235,7 +238,14 @@
   assert((Align <= unsigned(Target.getPointerAlign(0))/8)
          && "Can't align more than pointer yet");
   Types[needsCopyDispose*2 + 4] = LTy;
-  return llvm::StructType::get(VMContext, Types, false);
+  
+  const llvm::Type *T = llvm::StructType::get(VMContext, Types, false);
+  
+  cast<llvm::OpaqueType>(ByRefTypeHolder.get())->refineAbstractTypeTo(T);
+  CGM.getModule().addTypeName("struct.__block_byref_" + D->getNameAsString(), 
+                              ByRefTypeHolder.get());
+  
+  return ByRefTypeHolder.get();
 }
 
 /// EmitLocalBlockVarDecl - Emit code and set up an entry in LocalDeclMap for a
@@ -413,8 +423,7 @@
     V = Builder.CreateIntToPtr(V, PtrToInt8Ty, "isa");
     Builder.CreateStore(V, isa_field);
 
-    V = Builder.CreateBitCast(DeclPtr, PtrToInt8Ty, "forwarding");
-    Builder.CreateStore(V, forwarding_field);
+    Builder.CreateStore(DeclPtr, forwarding_field);
 
     V = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), flags);
     Builder.CreateStore(V, flags_field);

Modified: cfe/trunk/test/CodeGen/blocks-seq.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks-seq.c?rev=81423&r1=81422&r2=81423&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/blocks-seq.c (original)
+++ cfe/trunk/test/CodeGen/blocks-seq.c Wed Sep  9 20:32:12 2009
@@ -2,14 +2,12 @@
 // builds with and without asserts. We need a better solution for this.
 
 // RUN: clang-cc -fblocks -triple x86_64-apple-darwin10 -emit-llvm-bc -o - %s | opt -strip | llvm-dis > %t &&
-// RUN: grep '%7 = call i32 (...)\* @rhs()' %t | count 1 &&
-// RUN: grep '%8 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
-// RUN: grep '%9 = bitcast i8\*\* %8 to %0\*\*' %t | count 1 &&
-// RUN: grep '%10 = load %0\*\* %9' %t | count 1 &&
-// RUN: grep '%12 = call i32 (...)\* @rhs()' %t | count 1 &&
-// RUN: grep '%13 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
-// RUN: grep '%14 = bitcast i8\*\* %13 to %0\*\*' %t | count 1 &&
-// RUN: grep '%15 = load %0\*\* %14' %t | count 1
+// RUN: grep '%6 = call i32 (...)\* @rhs()' %t | count 1 &&
+// RUN: grep '%7 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
+// RUN: grep '%8 = load %0\*\* %7' %t | count 1 &&
+// RUN: grep '%10 = call i32 (...)\* @rhs()' %t | count 1 &&
+// RUN: grep '%11 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1 &&
+// RUN: grep '%12 = load %0\*\* %11' %t | count 1
 
 int rhs();
 





More information about the cfe-commits mailing list