]> granicus.if.org Git - clang/commitdiff
Simplify test to check an aggregate argument that has non trivial constructor or...
authorDevang Patel <dpatel@apple.com>
Wed, 16 Feb 2011 01:11:51 +0000 (01:11 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 16 Feb 2011 01:11:51 +0000 (01:11 +0000)
This patch rewrites r125142.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125632 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CodeGenFunction.h

index 11eeecba60ba3ef835bc7cc53fff75d531be0de5..ae84b6196dfaf802a850327b328b5353c59ef408 100644 (file)
@@ -898,7 +898,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
           V = EmitScalarConversion(V, Ty, Arg->getType());
         }
       }
-      EmitParmDecl(*Arg, V, true /*ABIArgInfo::Indirect*/);
+      EmitParmDecl(*Arg, V);
       break;
     }
 
index 2debea1733eb3a461d1cb4aea3226d014183a8d0..9296b42e77dd9765ffad2bb95e830aec6245d2b3 100644 (file)
@@ -1741,8 +1741,7 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const ValueDecl *VD,
 
 /// EmitDeclare - Emit local variable declaration debug info.
 void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
-                              llvm::Value *Storage, CGBuilderTy &Builder,
-                              bool IndirectArgument) {
+                              llvm::Value *Storage, CGBuilderTy &Builder) {
   assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
 
   llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
@@ -1758,17 +1757,19 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
   if (!Ty)
     return;
 
-  // If an aggregate variable has non trivial destructor or non trivial copy
-  // constructor than it is pass indirectly. Let debug info know about this
-  // by using reference of the aggregate type as a argument type.
-  if (IndirectArgument && VD->getType()->isClassType())
-    Ty = DBuilder.CreateReferenceType(Ty);
-
-  // If Storage is an aggregate returned as 'sret' then let debugger know
-  // about this.
-  if (llvm::Argument *Arg = dyn_cast<llvm::Argument>(Storage))
+  if (llvm::Argument *Arg = dyn_cast<llvm::Argument>(Storage)) {
+    // If Storage is an aggregate returned as 'sret' then let debugger know
+    // about this.
     if (Arg->hasStructRetAttr())
       Ty = DBuilder.CreateReferenceType(Ty);
+    else if (CXXRecordDecl *Record = VD->getType()->getAsCXXRecordDecl()) {
+      // If an aggregate variable has non trivial destructor or non trivial copy
+      // constructor than it is pass indirectly. Let debug info know about this
+      // by using reference of the aggregate type as a argument type.
+      if (!Record->hasTrivialCopyConstructor() || !Record->hasTrivialDestructor())
+        Ty = DBuilder.CreateReferenceType(Ty);
+    }
+  }
       
   // Get location information.
   unsigned Line = getLineNumber(VD->getLocation());
@@ -1930,10 +1931,8 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
 /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
 /// variable declaration.
 void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
-                                           CGBuilderTy &Builder, 
-                                           bool IndirectArgument) {
-  EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, Builder, 
-              IndirectArgument);
+                                           CGBuilderTy &Builder) {
+  EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, Builder);
 }
 
 
index 8efb7851817e55736e8e4727406b9b9c8e6e3613..6a9ab9c58b5293482c806fc18d75406d8b5a10e9 100644 (file)
@@ -178,7 +178,7 @@ public:
   /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
   /// variable declaration.
   void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
-                                CGBuilderTy &Builder, bool IndirectArg = false);
+                                CGBuilderTy &Builder);
 
   /// EmitGlobalVariable - Emit information about a global variable.
   void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
@@ -194,7 +194,7 @@ public:
 private:
   /// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
   void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
-                   CGBuilderTy &Builder, bool IndirectArgument = false);
+                   CGBuilderTy &Builder);
 
   /// EmitDeclare - Emit call to llvm.dbg.declare for a variable
   /// declaration from an enclosing block.
index 4dd788b7991783cb7fdb6f3ff61811b9c4121f90..c31840a78e2a8f4e824f1c191158b1d993501eef 100644 (file)
@@ -927,8 +927,7 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D,
 
 /// Emit an alloca (or GlobalValue depending on target)
 /// for the specified parameter and set up LocalDeclMap.
-void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg, 
-                                   bool IndirectArg) {
+void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
   // FIXME: Why isn't ImplicitParamDecl a ParmVarDecl?
   assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
          "Invalid argument to EmitParmDecl");
@@ -957,6 +956,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg,
   // Emit debug info for param declaration.
   if (CGDebugInfo *DI = getDebugInfo()) {
     DI->setLocation(D.getLocation());
-    DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder, IndirectArg);
+    DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder);
   }
 }
index d52a4812690a0626931efa066ed89032ff4098b1..5ea1565fc315ecc1f33fa9e6047e811b39321042 100644 (file)
@@ -1435,8 +1435,7 @@ public:
                          llvm::GlobalValue::LinkageTypes Linkage);
 
   /// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
-  void EmitParmDecl(const VarDecl &D, llvm::Value *Arg, 
-                    bool IndirectArgument = false);
+  void EmitParmDecl(const VarDecl &D, llvm::Value *Arg);
 
   //===--------------------------------------------------------------------===//
   //                             Statement Emission