[cfe-commits] r125142 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CGDebugInfo.cpp CGDebugInfo.h CGDecl.cpp CodeGenFunction.h

Devang Patel dpatel at apple.com
Tue Feb 8 16:37:30 PST 2011


Author: dpatel
Date: Tue Feb  8 18:37:30 2011
New Revision: 125142

URL: http://llvm.org/viewvc/llvm-project?rev=125142&view=rev
Log:
If an aggregate argument is passed indirectly because it has non trivial
destructor or copy constructor than let debug info know about it.

Radar 8945514.


Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.h
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=125142&r1=125141&r2=125142&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Feb  8 18:37:30 2011
@@ -898,7 +898,7 @@
           V = EmitScalarConversion(V, Ty, Arg->getType());
         }
       }
-      EmitParmDecl(*Arg, V);
+      EmitParmDecl(*Arg, V, true /*ABIArgInfo::Indirect*/);
       break;
     }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=125142&r1=125141&r2=125142&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb  8 18:37:30 2011
@@ -1735,7 +1735,8 @@
 
 /// EmitDeclare - Emit local variable declaration debug info.
 void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
-                              llvm::Value *Storage, CGBuilderTy &Builder) {
+                              llvm::Value *Storage, CGBuilderTy &Builder,
+                              bool IndirectArgument) {
   assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
 
   llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
@@ -1751,6 +1752,12 @@
   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()->isRecordType())
+    Ty = DBuilder.CreateReferenceType(Ty);
+
   // Get location information.
   unsigned Line = getLineNumber(VD->getLocation());
   unsigned Column = getColumnNumber(VD->getLocation());
@@ -1911,8 +1918,10 @@
 /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
 /// variable declaration.
 void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
-                                           CGBuilderTy &Builder) {
-  EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, Builder);
+                                           CGBuilderTy &Builder, 
+                                           bool IndirectArgument) {
+  EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, Builder, 
+              IndirectArgument);
 }
 
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=125142&r1=125141&r2=125142&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Feb  8 18:37:30 2011
@@ -178,7 +178,7 @@
   /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument
   /// variable declaration.
   void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
-                                CGBuilderTy &Builder);
+                                CGBuilderTy &Builder, bool IndirectArg = false);
 
   /// EmitGlobalVariable - Emit information about a global variable.
   void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
@@ -194,7 +194,7 @@
 private:
   /// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
   void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
-                   CGBuilderTy &Builder);
+                   CGBuilderTy &Builder, bool IndirectArgument = false);
 
   /// EmitDeclare - Emit call to llvm.dbg.declare for a variable
   /// declaration from an enclosing block.

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=125142&r1=125141&r2=125142&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Feb  8 18:37:30 2011
@@ -927,7 +927,8 @@
 
 /// 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) {
+void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg, 
+                                   bool IndirectArg) {
   // FIXME: Why isn't ImplicitParamDecl a ParmVarDecl?
   assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
          "Invalid argument to EmitParmDecl");
@@ -956,6 +957,6 @@
   // Emit debug info for param declaration.
   if (CGDebugInfo *DI = getDebugInfo()) {
     DI->setLocation(D.getLocation());
-    DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder);
+    DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder, IndirectArg);
   }
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=125142&r1=125141&r2=125142&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Feb  8 18:37:30 2011
@@ -1438,7 +1438,8 @@
                          llvm::GlobalValue::LinkageTypes Linkage);
 
   /// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
-  void EmitParmDecl(const VarDecl &D, llvm::Value *Arg);
+  void EmitParmDecl(const VarDecl &D, llvm::Value *Arg, 
+                    bool IndirectArgument = false);
 
   //===--------------------------------------------------------------------===//
   //                             Statement Emission





More information about the cfe-commits mailing list