From 34753802931fddcf57bd62c5b83bdca1a23017d7 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 16 Feb 2011 01:11:51 +0000 Subject: [PATCH] Simplify test to check an aggregate argument that has non trivial constructor or destructor. 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 | 2 +- lib/CodeGen/CGDebugInfo.cpp | 29 ++++++++++++++--------------- lib/CodeGen/CGDebugInfo.h | 4 ++-- lib/CodeGen/CGDecl.cpp | 5 ++--- lib/CodeGen/CodeGenFunction.h | 3 +-- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 11eeecba60..ae84b6196d 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -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; } diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 2debea1733..9296b42e77 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -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(Storage)) + if (llvm::Argument *Arg = dyn_cast(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); } diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 8efb785181..6a9ab9c58b 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -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. diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 4dd788b799..c31840a78e 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -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(D) || isa(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); } } diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index d52a481269..5ea1565fc3 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -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 -- 2.40.0