[llvm-commits] [llvm-gcc-4.2] r63133 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h
Evan Cheng
evan.cheng at apple.com
Tue Jan 27 13:46:11 PST 2009
Unless you believe RegionMap is going to be large. DenseMap is
probably the better choice.
Evan
On Jan 27, 2009, at 1:18 PM, Devang Patel wrote:
> Author: dpatel
> Date: Tue Jan 27 15:18:46 2009
> New Revision: 63133
>
> URL: http://llvm.org/viewvc/llvm-project?rev=63133&view=rev
> Log:
> Keep track of context info. findRegion() is not comprehensive enough
> to find appropriate scope in all cases, but it is significantly
> better then what llvm-gcc ever did for debug info.
>
>
> Modified:
> llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
> llvm-gcc-4.2/trunk/gcc/llvm-debug.h
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=63133&r1=63132&r2=63133&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Jan 27 15:18:46 2009
> @@ -214,39 +214,51 @@
> const char *FnName = GetNodeName(FnDecl);
> const char *LinkageName = getLinkageName(FnDecl);
>
> - tree func_type = TREE_TYPE(FnDecl);
> - llvm::SmallVector<llvm::DIDescriptor, 16> ArgTys;
> - // Add the result type at least.
> - ArgTys.push_back(getOrCreateType(TREE_TYPE(func_type)));
> -
> - // Set up remainder of arguments.
> - for (tree arg = TYPE_ARG_TYPES(func_type); arg; arg =
> TREE_CHAIN(arg)) {
> - tree formal_type = TREE_VALUE(arg);
> - if (formal_type == void_type_node) break;
> - ArgTys.push_back(getOrCreateType(formal_type));
> - }
> -
> - llvm::DIArray FnTypeArray =
> - DebugFactory.GetOrCreateArray(&ArgTys[0], ArgTys.size());
> -
> - llvm::DICompositeType FnTy =
> -
> DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
> - MainCompileUnit, "",
> - MainCompileUnit, 0, 0, 0, 0, 0,
> - llvm::DIType(), FnTypeArray);
> -
> - DISubprogram SP = DebugFactory.CreateSubprogram(MainCompileUnit,
> - FnName, FnName,
> LinkageName,
> - MainCompileUnit,
> CurLineNo,
> - FnTy,
> - Fn-
> >hasInternalLinkage(),
> - true /
> *definition*/,
> - &Filename,
> &Directory);
> + DISubprogram SP =
> + DebugFactory.CreateSubprogram(findRegion(FnDecl),
> + FnName, FnName, LinkageName,
> + MainCompileUnit, CurLineNo,
> + getOrCreateType(TREE_TYPE(FnDecl)),
> + Fn->hasInternalLinkage(),
> + true /*definition*/,
> + &Filename, &Directory);
>
> DebugFactory.InsertSubprogramStart(SP, CurBB);
>
> // Push function on region stack.
> RegionStack.push_back(SP);
> + RegionMap[FnDecl] = SP;
> +}
> +
> + /// findRegion - Find tree_node N's region.
> +DIDescriptor DebugInfo::findRegion(tree Node) {
> + if (Node == NULL_TREE)
> + return MainCompileUnit;
> +
> + std::map<tree_node *, DIDescriptor>::iterator I =
> RegionMap.find(Node);
> + if (I != RegionMap.end())
> + return I->second;
> +
> + if (TYPE_P (Node)) {
> + if (TYPE_CONTEXT (Node))
> + return findRegion (TYPE_CONTEXT(Node));
> + } else if (DECL_P (Node)) {
> + tree decl = Node;
> + tree context = NULL_TREE;
> + if (TREE_CODE (decl) != FUNCTION_DECL || ! DECL_VINDEX (decl))
> + context = DECL_CONTEXT (decl);
> + else
> + context = TYPE_MAIN_VARIANT
> + (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
> +
> + if (context && !TYPE_P (context))
> + context = NULL_TREE;
> + if (context != NULL_TREE)
> + return findRegion(context);
> + }
> +
> + // Otherwise main compile unit covers everything.
> + return MainCompileUnit;
> }
>
> /// EmitRegionStart- Constructs the debug code for entering a
> declarative
> @@ -397,7 +409,7 @@
> DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
>
> return
> DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
> - MainCompileUnit, "",
> + findRegion(type), "",
> MainCompileUnit, 0, 0, 0,
> 0, 0,
> llvm::DIType(),
> EltTypeArray);
> }
> @@ -412,7 +424,7 @@
> TREE_CODE(type) == BLOCK_POINTER_TYPE) ?
> DW_TAG_pointer_type :
> DW_TAG_reference_type;
> - return DebugFactory.CreateDerivedType(Tag, MainCompileUnit, "",
> + return DebugFactory.CreateDerivedType(Tag, findRegion(type), "",
> MainCompileUnit, 0 /*line
> no*/,
> NodeSizeInBits(type),
> NodeAlignInBits(type),
> @@ -466,7 +478,7 @@
> DebugFactory.GetOrCreateArray(&Subscripts[0], Subscripts.size());
>
> return
> DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type,
> - MainCompileUnit, "",
> + findRegion(type), "",
> MainCompileUnit,
> 0, NodeSizeInBits(type),
> NodeAlignInBits(type), 0, 0,
> @@ -500,7 +512,7 @@
> DirectoryAndFile(Loc.file, Directory, Filename);
> }
> return
> DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
> - MainCompileUnit,
> GetNodeName(type),
> + findRegion(type),
> GetNodeName(type),
> MainCompileUnit, Loc.line,
> NodeSizeInBits(type),
> NodeAlignInBits(type), 0, 0,
> @@ -526,7 +538,9 @@
> std::string Filename, Directory;
> DirectoryAndFile(Loc.file, Directory, Filename);
> llvm::DIType FwdDecl =
> - DebugFactory.CreateCompositeType(Tag, MainCompileUnit,
> GetNodeName(type),
> + DebugFactory.CreateCompositeType(Tag,
> + findRegion(type),
> + GetNodeName(type),
> MainCompileUnit, Loc.line,
> 0, 0, 0,
> llvm::DIType::FlagFwdDecl,
> llvm::DIType(), llvm::DIArray(),
> @@ -554,7 +568,7 @@
> // FIXME : name, size, align etc...
> DIType DTy =
> DebugFactory.CreateDerivedType(DW_TAG_inheritance,
> - MainCompileUnit,"",
> + findRegion(type),"",
> MainCompileUnit, 0,0,0,
> getInt64(BINFO_OFFSET(BInfo),
> 0),
> 0, BaseClass);
> @@ -595,7 +609,7 @@
> Flags = llvm::DIType::FlagPrivate;
>
> DIType DTy =
> - DebugFactory.CreateDerivedType(DW_TAG_member,
> MainCompileUnit,
> + DebugFactory.CreateDerivedType(DW_TAG_member,
> findRegion(Member),
> MemberName, MainCompileUnit,
> MemLoc.line,
> NodeSizeInBits(Member),
> NodeAlignInBits(FieldNodeType),
> @@ -622,7 +636,7 @@
> const char *LinkageName = getLinkageName(Member);
> DIType SPTy = getOrCreateType(TREE_TYPE(Member));
> DISubprogram SP =
> - DebugFactory.CreateSubprogram(MainCompileUnit, MemberName,
> MemberName,
> + DebugFactory.CreateSubprogram(findRegion(Member), MemberName,
> MemberName,
> LinkageName, MainCompileUnit,
> MemLoc.line, SPTy, false, false,
> &MemFilename, &MemDirectory);
> @@ -634,7 +648,7 @@
> DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
>
> llvm::DIType RealDecl =
> - DebugFactory.CreateCompositeType(Tag, MainCompileUnit,
> + DebugFactory.CreateCompositeType(Tag, findRegion(type),
> GetNodeName(type),
> MainCompileUnit, Loc.line,
> NodeSizeInBits(type),
> NodeAlignInBits(type),
> @@ -657,7 +671,7 @@
> expanded_location TypeDefLoc = GetNodeLocation(Name);
> std::string Filename, Directory;
> DirectoryAndFile(TypeDefLoc.file, Directory, Filename);
> - Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef,
> MainCompileUnit,
> + Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef,
> findRegion(type),
> GetNodeName(Name),
> MainCompileUnit,
> TypeDefLoc.line,
> 0 /*size*/,
> @@ -673,7 +687,7 @@
>
> if (TYPE_VOLATILE(type)) {
> Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type,
> - MainCompileUnit, "",
> + findRegion(type), "",
> MainCompileUnit, 0 /*line
> no*/,
> NodeSizeInBits(type),
> NodeAlignInBits(type),
> @@ -685,7 +699,7 @@
>
> if (TYPE_READONLY(type))
> Ty = DebugFactory.CreateDerivedType(DW_TAG_const_type,
> - MainCompileUnit, "",
> + findRegion(type), "",
> MainCompileUnit, 0 /*line
> no*/,
> NodeSizeInBits(type),
> NodeAlignInBits(type),
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=63133&r1=63132&r2=63133&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Tue Jan 27 15:18:46 2009
> @@ -66,6 +66,7 @@
> std::vector<DIDescriptor> RegionStack;
> // Stack to track
> declarative scopes.
>
> + std::map<tree_node *, DIDescriptor> RegionMap;
> public:
> DebugInfo(Module *m);
>
> @@ -126,7 +127,9 @@
>
> /// createCompileUnit - Create a new compile unit.
> DICompileUnit createCompileUnit(const std::string &FullPath);
> -
> +
> + /// findRegion - Find tree_node N's region.
> + DIDescriptor findRegion(tree_node *n);
> };
>
> } // end namespace llvm
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list