[cfe-commits] r159016 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/CodeGen/alloc_size.c test/CodeGenCXX/alloc_size.cpp

Nuno Lopes nunoplopes at sapo.pt
Fri Jun 22 11:01:38 PDT 2012


Author: nlopes
Date: Fri Jun 22 13:01:38 2012
New Revision: 159016

URL: http://llvm.org/viewvc/llvm-project?rev=159016&view=rev
Log:
revert CodeGen support for the alloc_size attribute until we finish the design of a more generic metadata node

Removed:
    cfe/trunk/test/CodeGen/alloc_size.c
    cfe/trunk/test/CodeGenCXX/alloc_size.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=159016&r1=159015&r2=159016&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Jun 22 13:01:38 2012
@@ -2085,25 +2085,6 @@
   CS.setAttributes(Attrs);
   CS.setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
 
-  // add metadata for __attribute__((alloc_size(foo)))
-  if (TargetDecl) {
-    if (const AllocSizeAttr* Attr = TargetDecl->getAttr<AllocSizeAttr>()) {
-      SmallVector<llvm::Value*, 4> Args;
-      llvm::IntegerType *Ty = llvm::IntegerType::getInt32Ty(getLLVMContext());
-      bool isMethod = false;
-      if (const CXXMethodDecl *MDecl = dyn_cast<CXXMethodDecl>(TargetDecl))
-        isMethod = MDecl->isInstance();
-
-      for (AllocSizeAttr::args_iterator I = Attr->args_begin(),
-           E = Attr->args_end(); I != E; ++I) {
-        Args.push_back(llvm::ConstantInt::get(Ty, *I + isMethod));
-      }
-
-      llvm::MDNode *MD = llvm::MDNode::get(getLLVMContext(), Args);
-      CS.getInstruction()->setMetadata("alloc_size", MD);
-    }
-  }
-
   // In ObjC ARC mode with no ObjC ARC exception safety, tell the ARC
   // optimizer it can aggressively ignore unwind edges.
   if (CGM.getLangOpts().ObjCAutoRefCount)

Removed: cfe/trunk/test/CodeGen/alloc_size.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alloc_size.c?rev=159015&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/alloc_size.c (original)
+++ cfe/trunk/test/CodeGen/alloc_size.c (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
-
-void *my_recalloc(void *, unsigned, unsigned) __attribute__((alloc_size(2,3))); 
-
-// CHECK: @f
-void* f() {
-  // CHECK: call i8* @my_recalloc{{.*}}, !alloc_size !0
-  return my_recalloc(0, 11, 27);
-}
-
-// CHECK: !0 = metadata !{i32 1, i32 2}

Removed: cfe/trunk/test/CodeGenCXX/alloc_size.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alloc_size.cpp?rev=159015&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/alloc_size.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/alloc_size.cpp (removed)
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
-
-struct foo {
-  void *my_alloc(unsigned) __attribute__((alloc_size(2)));
-  static void* static_alloc(unsigned) __attribute__((alloc_size(1)));
-};
-
-
-void* f(bool a) {
-  // CHECK: call i8* {{.*}}alloc{{.*}}, !alloc_size !0
-  // CHECK: call i8* {{.*}}static_alloc{{.*}}, !alloc_size !1
-  foo obj;
-  return a ? obj.my_alloc(2) :
-             foo::static_alloc(42);
-}
-
-// CHECK: !0 = metadata !{i32 1}
-// CHECK: !1 = metadata !{i32 0}





More information about the cfe-commits mailing list