[cfe-commits] r67898 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CodeGenFunction.cpp test/CodeGen/const-init.c

Eli Friedman eli.friedman at gmail.com
Fri Mar 27 20:24:56 PDT 2009


Author: efriedma
Date: Fri Mar 27 22:24:54 2009
New Revision: 67898

URL: http://llvm.org/viewvc/llvm-project?rev=67898&view=rev
Log:
Move where block-related variables are initialized so that block 
types don't get generated when blocks aren't used.


Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/test/CodeGen/const-init.c

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Mar 27 22:24:54 2009
@@ -625,6 +625,16 @@
       LocalDeclMap[VD] = i->second;
   }
 
+  // FIXME: We need to rearrange the code for copy/dispose so we have this
+  // sooner, so we can calculate offsets correctly.
+  if (!BlockHasCopyDispose)
+    BlockOffset = CGM.getTargetData()
+      .getTypeStoreSizeInBits(CGM.getGenericBlockLiteralType()) / 8;
+  else
+    BlockOffset = CGM.getTargetData()
+      .getTypeStoreSizeInBits(CGM.getGenericExtendedBlockLiteralType()) / 8;
+  BlockAlign = getContext().getTypeAlign(getContext().VoidPtrTy) / 8;
+
   const FunctionProtoType *FTy =
     cast<FunctionProtoType>(BExpr->getFunctionType());
 

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Mar 27 22:24:54 2009
@@ -29,16 +29,6 @@
     DebugInfo(0), SwitchInsn(0), CaseRangeBlock(0), InvokeDest(0) {
   LLVMIntTy = ConvertType(getContext().IntTy);
   LLVMPointerWidth = Target.getPointerWidth(0);
-
-  // FIXME: We need to rearrange the code for copy/dispose so we have this
-  // sooner, so we can calculate offsets correctly.
-  if (!BlockHasCopyDispose)
-    BlockOffset = CGM.getTargetData()
-      .getTypeStoreSizeInBits(CGM.getGenericBlockLiteralType()) / 8;
-  else
-    BlockOffset = CGM.getTargetData()
-      .getTypeStoreSizeInBits(CGM.getGenericExtendedBlockLiteralType()) / 8;
-  BlockAlign = getContext().getTypeAlign(getContext().VoidPtrTy) / 8;
 }
 
 ASTContext &CodeGenFunction::getContext() const {

Modified: cfe/trunk/test/CodeGen/const-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/const-init.c?rev=67898&r1=67897&r2=67898&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/const-init.c (original)
+++ cfe/trunk/test/CodeGen/const-init.c Fri Mar 27 22:24:54 2009
@@ -28,13 +28,13 @@
 _Complex double g1y = 1.0fi;
 // RUN: grep '@g1 = global %. { i8 1, i8 10 }' %t &&
 _Complex char g1 = (char) 1 + (char) 10 * 1i;
-// RUN: grep '@g2 = global .struct.__block_descriptor { i32 1, i32 10 }' %t &&
+// RUN: grep '@g2 = global %2 { i32 1, i32 10 }' %t &&
 _Complex int g2 = 1 + 10i;
 // RUN: grep '@g3 = global %. { float 1.000000e+00, float 1.000000e+01 }' %t &&
 _Complex float g3 = 1.0 + 10.0i;
 // RUN: grep '@g4 = global %. { double 1.000000e+00, double 1.000000e+01 }' %t &&
 _Complex double g4 = 1.0 + 10.0i;
-// RUN: grep '@g5 = global .struct.__block_descriptor zeroinitializer' %t &&
+// RUN: grep '@g5 = global %2 zeroinitializer' %t &&
 _Complex int g5 = (2 + 3i) == (5 + 7i);
 // RUN: grep '@g6 = global %. { double -1.100000e+01, double 2.900000e+01 }' %t &&
 _Complex double g6 = (2.0 + 3.0i) * (5.0 + 7.0i);





More information about the cfe-commits mailing list