[cfe-commits] r135029 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CodeGenFunction.h

John McCall rjmccall at apple.com
Tue Jul 12 20:03:51 PDT 2011


Author: rjmccall
Date: Tue Jul 12 22:03:51 2011
New Revision: 135029

URL: http://llvm.org/viewvc/llvm-project?rev=135029&view=rev
Log:
Aggressive dead code elimination.


Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=135029&r1=135028&r2=135029&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Jul 12 22:03:51 2011
@@ -1143,78 +1143,6 @@
                             addr);
 }
 
-/// EmitCXXAggrDestructorCall - calls the default destructor on array
-/// elements in reverse order of construction.
-void
-CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
-                                           const ArrayType *Array,
-                                           llvm::Value *This) {
-  const ConstantArrayType *CA = dyn_cast<ConstantArrayType>(Array);
-  assert(CA && "Do we support VLA for destruction ?");
-  uint64_t ElementCount = getContext().getConstantArrayElementCount(CA);
-  
-  const llvm::Type *SizeLTy = ConvertType(getContext().getSizeType());
-  llvm::Value* ElementCountPtr = llvm::ConstantInt::get(SizeLTy, ElementCount);
-  EmitCXXAggrDestructorCall(D, ElementCountPtr, This);
-}
-
-/// EmitCXXAggrDestructorCall - calls the default destructor on array
-/// elements in reverse order of construction.
-void
-CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
-                                           llvm::Value *UpperCount,
-                                           llvm::Value *This) {
-  const llvm::Type *SizeLTy = ConvertType(getContext().getSizeType());
-  llvm::Value *One = llvm::ConstantInt::get(SizeLTy, 1);
-  
-  // Create a temporary for the loop index and initialize it with count of
-  // array elements.
-  llvm::Value *IndexPtr = CreateTempAlloca(SizeLTy, "loop.index");
-
-  // Store the number of elements in the index pointer.
-  Builder.CreateStore(UpperCount, IndexPtr);
-
-  // Start the loop with a block that tests the condition.
-  llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
-  llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
-
-  EmitBlock(CondBlock);
-
-  llvm::BasicBlock *ForBody = createBasicBlock("for.body");
-
-  // Generate: if (loop-index != 0 fall to the loop body,
-  // otherwise, go to the block after the for-loop.
-  llvm::Value* zeroConstant =
-    llvm::Constant::getNullValue(SizeLTy);
-  llvm::Value *Counter = Builder.CreateLoad(IndexPtr);
-  llvm::Value *IsNE = Builder.CreateICmpNE(Counter, zeroConstant,
-                                            "isne");
-  // If the condition is true, execute the body.
-  Builder.CreateCondBr(IsNE, ForBody, AfterFor);
-
-  EmitBlock(ForBody);
-
-  llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
-  // Inside the loop body, emit the constructor call on the array element.
-  Counter = Builder.CreateLoad(IndexPtr);
-  Counter = Builder.CreateSub(Counter, One);
-  llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
-  EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false, Address);
-
-  EmitBlock(ContinueBlock);
-
-  // Emit the decrement of the loop counter.
-  Counter = Builder.CreateLoad(IndexPtr);
-  Counter = Builder.CreateSub(Counter, One, "dec");
-  Builder.CreateStore(Counter, IndexPtr);
-
-  // Finally, branch back up to the condition for the next iteration.
-  EmitBranch(CondBlock);
-
-  // Emit the fall-through block.
-  EmitBlock(AfterFor, true);
-}
-
 void
 CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
                                         CXXCtorType Type, bool ForVirtualBase,

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=135029&r1=135028&r2=135029&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Jul 12 22:03:51 2011
@@ -1702,16 +1702,8 @@
                                   CallExpr::const_arg_iterator ArgEnd,
                                   bool ZeroInitialization = false);
 
-  void EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
-                                 const ArrayType *Array,
-                                 llvm::Value *This);
-
   static Destroyer destroyCXXObject;
 
-  void EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
-                                 llvm::Value *NumElements,
-                                 llvm::Value *This);
-
   void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type,
                              bool ForVirtualBase, llvm::Value *This);
 





More information about the cfe-commits mailing list