[cfe-commits] r69337 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h test/CodeGen/blocks.c

Daniel Dunbar daniel at zuster.org
Thu Apr 16 17:48:04 PDT 2009


Author: ddunbar
Date: Thu Apr 16 19:48:04 2009
New Revision: 69337

URL: http://llvm.org/viewvc/llvm-project?rev=69337&view=rev
Log:
Attributes on block functions were not being set.
 - <rdar://problem/6800351> clang not producing correct large struct
   return code for Blocks

Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h
    cfe/trunk/test/CodeGen/blocks.c

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Apr 16 19:48:04 2009
@@ -670,6 +670,8 @@
                            Name,
                            &CGM.getModule());
 
+  CGM.SetInternalFunctionAttributes(BD, Fn, FI);
+
   StartFunction(BD, ResultType, Fn, Args,
                 BExpr->getBody()->getLocEnd());
   CurFuncDecl = OuterFuncDecl;

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Apr 16 19:48:04 2009
@@ -109,7 +109,8 @@
   FunctionArgList Args;
   llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD);
 
-  CGM.SetMethodAttributes(OMD, Fn);
+  const CGFunctionInfo &FI = CGM.getTypes().getFunctionInfo(OMD);
+  CGM.SetInternalFunctionAttributes(OMD, Fn, FI);
 
   Args.push_back(std::make_pair(OMD->getSelfDecl(), 
                                 OMD->getSelfDecl()->getType()));

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Apr 16 19:48:04 2009
@@ -340,14 +340,15 @@
     GV->setSection(SA->getName());
 }
 
-void CodeGenModule::SetMethodAttributes(const ObjCMethodDecl *MD,
-                                        llvm::Function *F) {
-  SetLLVMFunctionAttributes(MD, getTypes().getFunctionInfo(MD), F);
-  SetLLVMFunctionAttributesForDefinition(MD, F);
+void CodeGenModule::SetInternalFunctionAttributes(const Decl *D,
+                                                  llvm::Function *F,
+                                                  const CGFunctionInfo &FI) {
+  SetLLVMFunctionAttributes(D, FI, F);
+  SetLLVMFunctionAttributesForDefinition(D, F);
 
   F->setLinkage(llvm::Function::InternalLinkage);
 
-  SetCommonAttributes(MD, F);
+  SetCommonAttributes(D, F);
 }
 
 void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=69337&r1=69336&r2=69337&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Apr 16 19:48:04 2009
@@ -303,8 +303,12 @@
   void ErrorUnsupported(const Decl *D, const char *Type,
                         bool OmitOnError=false);
 
-  void SetMethodAttributes(const ObjCMethodDecl *MD,
-                           llvm::Function *F);
+  /// SetInternalFunctionAttributes - Set the attributes on the LLVM
+  /// function for the given decl and function info. This applies
+  /// attributes necessary for handling the ABI as well as user
+  /// specified attributes like section.
+  void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F,
+                                     const CGFunctionInfo &FI);
 
   /// SetLLVMFunctionAttributes - Set the LLVM function attributes
   /// (sext, zext, etc).

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

==============================================================================
--- cfe/trunk/test/CodeGen/blocks.c (original)
+++ cfe/trunk/test/CodeGen/blocks.c Thu Apr 16 19:48:04 2009
@@ -1,7 +1,20 @@
-// RUN: clang-cc %s -emit-llvm -o %t -fblocks
+// RUN: clang-cc -triple i386-unknown-unknown %s -emit-llvm -o %t -fblocks &&
 void (^f)(void) = ^{};
 
 // rdar://6768379
 int f0(int (^a0)()) {
   return a0(1, 2, 3);
 }
+
+// Verify that attributes on blocks are set correctly.
+typedef struct s0 T;
+struct s0 {
+  int a[64];
+};
+
+// RUN: grep 'internal void @__f2_block_invoke_(.struct.s0\* noalias sret .*, .*, .* byval .*)' %t &&
+struct s0 f2(struct s0 a0) {
+  return ^(struct s0 a1){ return a1; }(a0);
+}
+
+// RUN: true





More information about the cfe-commits mailing list