r221043 - CodeGen: Declutter the emitVirtualObjectDelete interface

David Majnemer david.majnemer at gmail.com
Sat Nov 1 00:37:17 PDT 2014


Author: majnemer
Date: Sat Nov  1 02:37:17 2014
New Revision: 221043

URL: http://llvm.org/viewvc/llvm-project?rev=221043&view=rev
Log:
CodeGen: Declutter the emitVirtualObjectDelete interface

No functionality change intended.

Modified:
    cfe/trunk/lib/CodeGen/CGCXXABI.h
    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
    cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=221043&r1=221042&r2=221043&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Sat Nov  1 02:37:17 2014
@@ -210,9 +210,8 @@ protected:
 
 public:
   virtual void emitVirtualObjectDelete(CodeGenFunction &CGF,
-                                       const FunctionDecl *OperatorDelete,
+                                       const CXXDeleteExpr *DE,
                                        llvm::Value *Ptr, QualType ElementType,
-                                       bool UseGlobalDelete,
                                        const CXXDestructorDecl *Dtor) = 0;
 
   virtual llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) = 0;

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=221043&r1=221042&r2=221043&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Sat Nov  1 02:37:17 2014
@@ -1420,10 +1420,9 @@ CodeGenFunction::pushCallObjectDeleteCle
 
 /// Emit the code for deleting a single object.
 static void EmitObjectDelete(CodeGenFunction &CGF,
-                             const FunctionDecl *OperatorDelete,
+                             const CXXDeleteExpr *DE,
                              llvm::Value *Ptr,
-                             QualType ElementType,
-                             bool UseGlobalDelete) {
+                             QualType ElementType) {
   // Find the destructor for the type, if applicable.  If the
   // destructor is virtual, we'll just emit the vcall and return.
   const CXXDestructorDecl *Dtor = nullptr;
@@ -1433,8 +1432,8 @@ static void EmitObjectDelete(CodeGenFunc
       Dtor = RD->getDestructor();
 
       if (Dtor->isVirtual()) {
-        CGF.CGM.getCXXABI().emitVirtualObjectDelete(
-            CGF, OperatorDelete, Ptr, ElementType, UseGlobalDelete, Dtor);
+        CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
+                                                    Dtor);
         return;
       }
     }
@@ -1443,6 +1442,7 @@ static void EmitObjectDelete(CodeGenFunc
   // Make sure that we call delete even if the dtor throws.
   // This doesn't have to a conditional cleanup because we're going
   // to pop it off in a second.
+  const FunctionDecl *OperatorDelete = DE->getOperatorDelete();
   CGF.EHStack.pushCleanup<CallObjectDelete>(NormalAndEHCleanup,
                                             Ptr, OperatorDelete, ElementType);
 
@@ -1619,8 +1619,7 @@ void CodeGenFunction::EmitCXXDeleteExpr(
   if (E->isArrayForm()) {
     EmitArrayDelete(*this, E, Ptr, DeleteTy);
   } else {
-    EmitObjectDelete(*this, E->getOperatorDelete(), Ptr, DeleteTy,
-                     E->isGlobalDelete());
+    EmitObjectDelete(*this, E, Ptr, DeleteTy);
   }
 
   EmitBlock(DeleteEnd);

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=221043&r1=221042&r2=221043&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Sat Nov  1 02:37:17 2014
@@ -106,10 +106,8 @@ public:
                                          llvm::Value *Addr,
                                          const MemberPointerType *MPT) override;
 
-  void emitVirtualObjectDelete(CodeGenFunction &CGF,
-                               const FunctionDecl *OperatorDelete,
+  void emitVirtualObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE,
                                llvm::Value *Ptr, QualType ElementType,
-                               bool UseGlobalDelete,
                                const CXXDestructorDecl *Dtor) override;
 
   void EmitFundamentalRTTIDescriptor(QualType Type);
@@ -851,9 +849,12 @@ bool ItaniumCXXABI::isZeroInitializable(
 
 /// The Itanium ABI always places an offset to the complete object
 /// at entry -2 in the vtable.
-void ItaniumCXXABI::emitVirtualObjectDelete(
-    CodeGenFunction &CGF, const FunctionDecl *OperatorDelete, llvm::Value *Ptr,
-    QualType ElementType, bool UseGlobalDelete, const CXXDestructorDecl *Dtor) {
+void ItaniumCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF,
+                                            const CXXDeleteExpr *DE,
+                                            llvm::Value *Ptr,
+                                            QualType ElementType,
+                                            const CXXDestructorDecl *Dtor) {
+  bool UseGlobalDelete = DE->isGlobalDelete();
   if (UseGlobalDelete) {
     // Derive the complete-object pointer, which is what we need
     // to pass to the deallocation function.
@@ -873,7 +874,8 @@ void ItaniumCXXABI::emitVirtualObjectDel
 
     // If we're supposed to call the global delete, make sure we do so
     // even if the destructor throws.
-    CGF.pushCallObjectDeleteCleanup(OperatorDelete, CompletePtr, ElementType);
+    CGF.pushCallObjectDeleteCleanup(DE->getOperatorDelete(), CompletePtr,
+                                    ElementType);
   }
 
   // FIXME: Provide a source location here even though there's no

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=221043&r1=221042&r2=221043&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Sat Nov  1 02:37:17 2014
@@ -66,10 +66,8 @@ public:
   StringRef GetPureVirtualCallName() override { return "_purecall"; }
   StringRef GetDeletedVirtualCallName() override { return "_purecall"; }
 
-  void emitVirtualObjectDelete(CodeGenFunction &CGF,
-                               const FunctionDecl *OperatorDelete,
+  void emitVirtualObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE,
                                llvm::Value *Ptr, QualType ElementType,
-                               bool UseGlobalDelete,
                                const CXXDestructorDecl *Dtor) override;
 
   llvm::GlobalVariable *getMSCompleteObjectLocator(const CXXRecordDecl *RD,
@@ -652,16 +650,19 @@ MicrosoftCXXABI::getRecordArgABI(const C
   llvm_unreachable("invalid enum");
 }
 
-void MicrosoftCXXABI::emitVirtualObjectDelete(
-    CodeGenFunction &CGF, const FunctionDecl *OperatorDelete, llvm::Value *Ptr,
-    QualType ElementType, bool UseGlobalDelete, const CXXDestructorDecl *Dtor) {
+void MicrosoftCXXABI::emitVirtualObjectDelete(CodeGenFunction &CGF,
+                                              const CXXDeleteExpr *DE,
+                                              llvm::Value *Ptr,
+                                              QualType ElementType,
+                                              const CXXDestructorDecl *Dtor) {
   // FIXME: Provide a source location here even though there's no
   // CXXMemberCallExpr for dtor call.
+  bool UseGlobalDelete = DE->isGlobalDelete();
   CXXDtorType DtorType = UseGlobalDelete ? Dtor_Complete : Dtor_Deleting;
   llvm::Value *MDThis =
       EmitVirtualDestructorCall(CGF, Dtor, DtorType, Ptr, /*CE=*/nullptr);
   if (UseGlobalDelete)
-    CGF.EmitDeleteCall(OperatorDelete, MDThis, ElementType);
+    CGF.EmitDeleteCall(DE->getOperatorDelete(), MDThis, ElementType);
 }
 
 /// \brief Gets the offset to the virtual base that contains the vfptr for





More information about the cfe-commits mailing list