Skip to content

Commit

Permalink
Split out filename & directory from DIFile to start generalizing over…
Browse files Browse the repository at this point in the history
… DIScopes

This is the first step to making all DIScopes have a common metadata prefix (so
that things (using directives, for example) that can appear in any scope can be
added to that common prefix). DIFile is itself a DIScope so the common prefix
of all DIScopes cannot be a DIFile - instead it's the raw filename/directory
name pair.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177239 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dwblaikie committed Mar 17, 2013
1 parent 14de1a8 commit b4cf0ab
Show file tree
Hide file tree
Showing 87 changed files with 330 additions and 220 deletions.
2 changes: 0 additions & 2 deletions include/llvm/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ namespace llvm {
if (DbgNode && !isFile())
DbgNode = 0;
}
StringRef getFilename() const { return getStringField(1); }
StringRef getDirectory() const { return getStringField(2); }
bool Verify() const;
};

Expand Down
7 changes: 5 additions & 2 deletions lib/IR/DIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,14 @@ void DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
/// for a file.
DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
assert(!Filename.empty() && "Unable to create file without name");
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
Value *Pair[] {
MDString::get(VMContext, Filename),
MDString::get(VMContext, Directory),
};
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
MDNode::get(VMContext, Pair)
};
return DIFile(MDNode::get(VMContext, Elts));
}

Expand Down
34 changes: 20 additions & 14 deletions lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,28 @@ bool DIDescriptor::Verify() const {
DITemplateValueParameter(DbgNode).Verify());
}

StringRef
DIDescriptor::getStringField(unsigned Elt) const {
if (DbgNode == 0)
return StringRef();
static Value *getField(const MDNode *DbgNode, unsigned Elt) {
if (DbgNode == 0 || Elt >= DbgNode->getNumOperands())
return 0;
return DbgNode->getOperand(Elt);
}

if (Elt < DbgNode->getNumOperands())
if (MDString *MDS = dyn_cast_or_null<MDString>(DbgNode->getOperand(Elt)))
return MDS->getString();
static const MDNode *getNodeField(const MDNode *DbgNode, unsigned Elt) {
if (const MDNode *R = dyn_cast_or_null<MDNode>(getField(DbgNode, Elt)))
return R;
return 0;
}

static StringRef getStringField(const MDNode *DbgNode, unsigned Elt) {
if (MDString *MDS = dyn_cast_or_null<MDString>(getField(DbgNode, Elt)))
return MDS->getString();
return StringRef();
}

StringRef DIDescriptor::getStringField(unsigned Elt) const {
return ::getStringField(DbgNode, Elt);
}

uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const {
if (DbgNode == 0)
return 0;
Expand Down Expand Up @@ -531,7 +541,7 @@ bool DINameSpace::Verify() const {

/// \brief Verify that the file descriptor is well formed.
bool DIFile::Verify() const {
return isFile() && DbgNode->getNumOperands() == 3;
return isFile() && DbgNode->getNumOperands() == 2;
}

/// \brief Verify that the enumerator descriptor is well formed.
Expand Down Expand Up @@ -661,9 +671,7 @@ StringRef DIScope::getFilename() const {
return DINameSpace(DbgNode).getFilename();
if (isType())
return DIType(DbgNode).getFilename();
if (isFile())
return DIFile(DbgNode).getFilename();
llvm_unreachable("Invalid DIScope!");
return ::getStringField(getNodeField(DbgNode, 1), 0);
}

StringRef DIScope::getDirectory() const {
Expand All @@ -681,9 +689,7 @@ StringRef DIScope::getDirectory() const {
return DINameSpace(DbgNode).getDirectory();
if (isType())
return DIType(DbgNode).getDirectory();
if (isFile())
return DIFile(DbgNode).getDirectory();
llvm_unreachable("Invalid DIScope!");
return ::getStringField(getNodeField(DbgNode, 1), 1);
}

DIArray DICompileUnit::getEnumTypes() const {
Expand Down
3 changes: 2 additions & 1 deletion test/CodeGen/ARM/2010-08-04-StackVariable.ll
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone

!0 = metadata !{i32 786478, i32 0, metadata !1, metadata !"SVal", metadata !"SVal", metadata !"", metadata !2, i32 11, metadata !14, i1 false, i1 false, i32 0, i32 0, null, i1 false, i1 false, null} ; [ DW_TAG_subprogram ]
!1 = metadata !{i32 786451, metadata !2, metadata !"SVal", metadata !2, i32 1, i64 128, i64 64, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_structure_type ]
!2 = metadata !{i32 786473, metadata !"small.cc", metadata !"/Users/manav/R8248330"} ; [ DW_TAG_file_type ]
!2 = metadata !{i32 786473, metadata !48} ; [ DW_TAG_file_type ]
!3 = metadata !{i32 786449, i32 0, i32 4, metadata !2, metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 false, metadata !"", i32 0, metadata !47, metadata !47, metadata !46, metadata !47, metadata !""} ; [ DW_TAG_compile_unit ]
!4 = metadata !{metadata !5, metadata !7, metadata !0, metadata !9}
!5 = metadata !{i32 786445, metadata !1, metadata !"Data", metadata !2, i32 7, i64 64, i64 64, i64 0, i32 0, metadata !6} ; [ DW_TAG_member ]
Expand Down Expand Up @@ -124,3 +124,4 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
!45 = metadata !{i32 27, i32 0, metadata !39, null}
!46 = metadata !{metadata !0, metadata !9, metadata !16, metadata !17, metadata !20}
!47 = metadata !{i32 0}
!48 = metadata !{metadata !"small.cc", metadata !"/Users/manav/R8248330"}
17 changes: 9 additions & 8 deletions test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,9 @@ entry:
}

!llvm.dbg.cu = !{!2}
!40 = metadata !{metadata !0, metadata !6, metadata !7, metadata !8, metadata !9}
!41 = metadata !{metadata !13, metadata !14, metadata !15, metadata !16, metadata !17}
!42 = metadata !{metadata !10, metadata !11}
!43 = metadata !{metadata !18, metadata !19}
!44 = metadata !{metadata !21, metadata !22}
!45 = metadata !{metadata !24, metadata !25}
!46 = metadata !{metadata !27, metadata !28}

!0 = metadata !{i32 786478, i32 0, metadata !1, metadata !"get1", metadata !"get1", metadata !"get1", metadata !1, i32 4, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 true, i8 (i8)* @get1, null, null, metadata !42, i32 4} ; [ DW_TAG_subprogram ]
!1 = metadata !{i32 786473, metadata !"foo.c", metadata !"/tmp/"} ; [ DW_TAG_file_type ]
!1 = metadata !{i32 786473, metadata !47} ; [ DW_TAG_file_type ]
!2 = metadata !{i32 786449, i32 0, i32 1, metadata !1, metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2369.8)", i1 true, metadata !"", i32 0, null, null, metadata !40, metadata !41, metadata !""} ; [ DW_TAG_compile_unit ]
!3 = metadata !{i32 786453, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
!4 = metadata !{metadata !5, metadata !5}
Expand Down Expand Up @@ -124,3 +117,11 @@ entry:
!37 = metadata !{i32 13, i32 0, metadata !26, null}
!38 = metadata !{i32 16, i32 0, metadata !9, null}
!39 = metadata !{i32 16, i32 0, metadata !29, null}
!40 = metadata !{metadata !0, metadata !6, metadata !7, metadata !8, metadata !9}
!41 = metadata !{metadata !13, metadata !14, metadata !15, metadata !16, metadata !17}
!42 = metadata !{metadata !10, metadata !11}
!43 = metadata !{metadata !18, metadata !19}
!44 = metadata !{metadata !21, metadata !22}
!45 = metadata !{metadata !24, metadata !25}
!46 = metadata !{metadata !27, metadata !28}
!47 = metadata !{metadata !"foo.c", metadata !"/tmp/"}
17 changes: 9 additions & 8 deletions test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,10 @@ define i32 @get5(i32 %a) nounwind optsize ssp {
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone

!llvm.dbg.cu = !{!0}
!40 = metadata !{metadata !1, metadata !6, metadata !7, metadata !8, metadata !9}
!42 = metadata !{metadata !10, metadata !11}
!43 = metadata !{metadata !13, metadata !14}
!44 = metadata !{metadata !16, metadata !17}
!45 = metadata !{metadata !19, metadata !20}
!46 = metadata !{metadata !27, metadata !28}
!41 = metadata !{metadata !22, metadata !23, metadata !24, metadata !25, metadata !26}

!0 = metadata !{i32 786449, i32 0, i32 12, metadata !2, metadata !"clang", i1 true, metadata !"", i32 0, null, null, metadata !40, metadata !41, null} ; [ DW_TAG_compile_unit ]
!1 = metadata !{i32 786478, i32 0, metadata !2, metadata !"get1", metadata !"get1", metadata !"", metadata !2, i32 5, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 (i32)* @get1, null, null, metadata !42, i32 5} ; [ DW_TAG_subprogram ]
!2 = metadata !{i32 786473, metadata !"ss3.c", metadata !"/private/tmp", metadata !0} ; [ DW_TAG_file_type ]
!2 = metadata !{i32 786473, metadata !47} ; [ DW_TAG_file_type ]
!3 = metadata !{i32 786453, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
!4 = metadata !{metadata !5}
!5 = metadata !{i32 786468, metadata !0, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
Expand Down Expand Up @@ -121,3 +114,11 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
!37 = metadata !{i32 14, i32 32, metadata !21, null}
!38 = metadata !{i32 17, i32 16, metadata !9, null}
!39 = metadata !{i32 17, i32 32, metadata !29, null}
!40 = metadata !{metadata !1, metadata !6, metadata !7, metadata !8, metadata !9}
!41 = metadata !{metadata !22, metadata !23, metadata !24, metadata !25, metadata !26}
!42 = metadata !{metadata !10, metadata !11}
!43 = metadata !{metadata !13, metadata !14}
!44 = metadata !{metadata !16, metadata !17}
!45 = metadata !{metadata !19, metadata !20}
!46 = metadata !{metadata !27, metadata !28}
!47 = metadata !{metadata !"ss3.c", metadata !"/private/tmp"}
7 changes: 4 additions & 3 deletions test/CodeGen/ARM/debug-info-arg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ declare void @foobar(i64, i64)
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone

!llvm.dbg.cu = !{!0}
!30 = metadata !{metadata !1}
!31 = metadata !{metadata !5, metadata !13, metadata !14, metadata !17, metadata !18, metadata!19}

!0 = metadata !{i32 786449, i32 0, i32 12, metadata !2, metadata !"Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)", i1 true, metadata !"", i32 0, null, null, metadata !30, null, null} ; [ DW_TAG_compile_unit ]
!1 = metadata !{i32 786478, i32 0, metadata !2, metadata !"foo", metadata !"foo", metadata !"", metadata !2, i32 11, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void (%struct.tag_s*, %struct.tag_s*, i64, i64, %struct.tag_s*, %struct.tag_s*)* @foo, null, null, metadata !31, i32 11} ; [ DW_TAG_subprogram ]
!2 = metadata !{i32 786473, metadata !"one.c", metadata !"/Volumes/Athwagate/R10048772"} ; [ DW_TAG_file_type ]
!2 = metadata !{i32 786473, metadata !32} ; [ DW_TAG_file_type ]
!3 = metadata !{i32 786453, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
!4 = metadata !{null}
!5 = metadata !{i32 786689, metadata !1, metadata !"this", metadata !2, i32 16777227, metadata !6, i32 0, null} ; [ DW_TAG_arg_variable ]
Expand Down Expand Up @@ -63,3 +61,6 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
!27 = metadata !{i32 786443, metadata !1, i32 11, i32 107, metadata !2, i32 0} ; [ DW_TAG_lexical_block ]
!28 = metadata !{i32 13, i32 5, metadata !27, null}
!29 = metadata !{i32 14, i32 1, metadata !27, null}
!30 = metadata !{metadata !1}
!31 = metadata !{metadata !5, metadata !13, metadata !14, metadata !17, metadata !18, metadata!19}
!32 = metadata !{metadata !"one.c", metadata !"/Volumes/Athwagate/R10048772"}
Loading

0 comments on commit b4cf0ab

Please sign in to comment.