[Debug Info] remove DITrivialType and use null to represent unspecified param.

Per feedback on r214111, we are going to use null to represent unspecified
parameter. If the type array is {null}, it means a function that returns void;
If the type array is {null, null}, it means a variadic function that returns
void. In summary if we have more than one element in the type array and the last
element is null, it is a variadic function.

rdar://17628609


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214189 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Manman Ren
2014-07-29 18:20:39 +00:00
parent 52f23be080
commit 23ab342d96
7 changed files with 22 additions and 71 deletions

View File

@ -465,7 +465,7 @@ namespace llvm {
/// createUnspecifiedParameter - Create unspecified parameter type /// createUnspecifiedParameter - Create unspecified parameter type
/// for a subroutine type. /// for a subroutine type.
DITrivialType createUnspecifiedParameter(); DIBasicType createUnspecifiedParameter();
/// getOrCreateArray - Get a DIArray, create one if required. /// getOrCreateArray - Get a DIArray, create one if required.
DIArray getOrCreateArray(ArrayRef<Value *> Elements); DIArray getOrCreateArray(ArrayRef<Value *> Elements);

View File

@ -129,7 +129,6 @@ public:
bool isCompositeType() const; bool isCompositeType() const;
bool isSubroutineType() const; bool isSubroutineType() const;
bool isBasicType() const; bool isBasicType() const;
bool isTrivialType() const;
bool isVariable() const; bool isVariable() const;
bool isSubprogram() const; bool isSubprogram() const;
bool isGlobalVariable() const; bool isGlobalVariable() const;
@ -142,7 +141,6 @@ public:
bool isSubrange() const; bool isSubrange() const;
bool isEnumerator() const; bool isEnumerator() const;
bool isType() const; bool isType() const;
bool isUnspecifiedParameter() const;
bool isTemplateTypeParameter() const; bool isTemplateTypeParameter() const;
bool isTemplateValueParameter() const; bool isTemplateValueParameter() const;
bool isObjCProperty() const; bool isObjCProperty() const;
@ -308,36 +306,15 @@ public:
/// Verify - Verify that a type descriptor is well formed. /// Verify - Verify that a type descriptor is well formed.
bool Verify() const; bool Verify() const;
DIScopeRef getContext() const { DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); }
assert(!isTrivialType() && "no context for DITrivialType"); StringRef getName() const { return getStringField(3); }
return getFieldAs<DIScopeRef>(2); unsigned getLineNumber() const { return getUnsignedField(4); }
} uint64_t getSizeInBits() const { return getUInt64Field(5); }
StringRef getName() const { uint64_t getAlignInBits() const { return getUInt64Field(6); }
assert(!isTrivialType() && "no name for DITrivialType");
return getStringField(3);
}
unsigned getLineNumber() const {
assert(!isTrivialType() && "no line number for DITrivialType");
return getUnsignedField(4);
}
uint64_t getSizeInBits() const {
assert(!isTrivialType() && "no SizeInBits for DITrivialType");
return getUInt64Field(5);
}
uint64_t getAlignInBits() const {
assert(!isTrivialType() && "no AlignInBits for DITrivialType");
return getUInt64Field(6);
}
// FIXME: Offset is only used for DW_TAG_member nodes. Making every type // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
// carry this is just plain insane. // carry this is just plain insane.
uint64_t getOffsetInBits() const { uint64_t getOffsetInBits() const { return getUInt64Field(7); }
assert(!isTrivialType() && "no OffsetInBits for DITrivialType"); unsigned getFlags() const { return getUnsignedField(8); }
return getUInt64Field(7);
}
unsigned getFlags() const {
assert(!isTrivialType() && "no flag for DITrivialType");
return getUnsignedField(8);
}
bool isPrivate() const { return (getFlags() & FlagPrivate) != 0; } bool isPrivate() const { return (getFlags() & FlagPrivate) != 0; }
bool isProtected() const { return (getFlags() & FlagProtected) != 0; } bool isProtected() const { return (getFlags() & FlagProtected) != 0; }
bool isForwardDecl() const { return (getFlags() & FlagFwdDecl) != 0; } bool isForwardDecl() const { return (getFlags() & FlagFwdDecl) != 0; }
@ -370,12 +347,6 @@ public:
void replaceAllUsesWith(MDNode *D); void replaceAllUsesWith(MDNode *D);
}; };
class DITrivialType : public DIType {
public:
explicit DITrivialType(const MDNode *N = nullptr) : DIType(N) {}
bool Verify() const;
};
/// DIBasicType - A basic type, like 'int' or 'float'. /// DIBasicType - A basic type, like 'int' or 'float'.
class DIBasicType : public DIType { class DIBasicType : public DIType {
public: public:

View File

@ -469,11 +469,13 @@ DIE *DwarfDebug::createScopeChildrenDIE(
// If this is a variadic function, add an unspecified parameter. // If this is a variadic function, add an unspecified parameter.
DISubprogram SP(Scope->getScopeNode()); DISubprogram SP(Scope->getScopeNode());
DITypeArray FnArgs = SP.getType().getTypeArray(); DITypeArray FnArgs = SP.getType().getTypeArray();
if (resolve(FnArgs.getElement(FnArgs.getNumElements() - 1)) // If we have a single element of null, it is a function that returns void.
.isUnspecifiedParameter()) { // If we have more than one elements and the last one is null, it is a
// variadic function.
if (FnArgs.getNumElements() > 1 &&
!resolve(FnArgs.getElement(FnArgs.getNumElements() - 1)))
Children.push_back( Children.push_back(
make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters)); make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
}
} }
// Collect lexical scope children first. // Collect lexical scope children first.

View File

@ -1132,7 +1132,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) { void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) {
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIType Ty = resolve(Args.getElement(i)); DIType Ty = resolve(Args.getElement(i));
if (Ty.isUnspecifiedParameter()) { if (!Ty) {
assert(i == N-1 && "Unspecified parameter must be the last argument"); assert(i == N-1 && "Unspecified parameter must be the last argument");
createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer); createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
} else { } else {
@ -1168,7 +1168,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
bool isPrototyped = true; bool isPrototyped = true;
if (Elements.getNumElements() == 2 && if (Elements.getNumElements() == 2 &&
resolve(Elements.getElement(1)).isUnspecifiedParameter()) !resolve(Elements.getElement(1)))
isPrototyped = false; isPrototyped = false;
constructSubprogramArguments(Buffer, Elements); constructSubprogramArguments(Buffer, Elements);

View File

@ -875,11 +875,8 @@ void DIBuilder::retainType(DIType T) {
/// createUnspecifiedParameter - Create unspeicified type descriptor /// createUnspecifiedParameter - Create unspeicified type descriptor
/// for the subroutine type. /// for the subroutine type.
DITrivialType DIBuilder::createUnspecifiedParameter() { DIBasicType DIBuilder::createUnspecifiedParameter() {
Value *Elts[] = { return DIBasicType(nullptr);
GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_parameters)
};
return DITrivialType(MDNode::get(VMContext, Elts));
} }
/// createForwardDecl - Create a temporary forward-declared type that /// createForwardDecl - Create a temporary forward-declared type that

View File

@ -39,7 +39,6 @@ bool DIDescriptor::Verify() const {
return DbgNode && return DbgNode &&
(DIDerivedType(DbgNode).Verify() || (DIDerivedType(DbgNode).Verify() ||
DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() || DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() ||
DITrivialType(DbgNode).Verify() ||
DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() || DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() ||
DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() || DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() ||
DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() || DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() ||
@ -155,10 +154,6 @@ MDNode *DIVariable::getInlinedAt() const { return getNodeField(DbgNode, 7); }
// Predicates // Predicates
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
bool DIDescriptor::isTrivialType() const {
return DbgNode && getTag() == dwarf::DW_TAG_unspecified_parameters;
}
bool DIDescriptor::isSubroutineType() const { bool DIDescriptor::isSubroutineType() const {
return isCompositeType() && getTag() == dwarf::DW_TAG_subroutine_type; return isCompositeType() && getTag() == dwarf::DW_TAG_subroutine_type;
} }
@ -233,8 +228,7 @@ bool DIDescriptor::isVariable() const {
/// isType - Return true if the specified tag is legal for DIType. /// isType - Return true if the specified tag is legal for DIType.
bool DIDescriptor::isType() const { bool DIDescriptor::isType() const {
return isBasicType() || isCompositeType() || isDerivedType() || return isBasicType() || isCompositeType() || isDerivedType();
isTrivialType();
} }
/// isSubprogram - Return true if the specified tag is legal for /// isSubprogram - Return true if the specified tag is legal for
@ -250,12 +244,6 @@ bool DIDescriptor::isGlobalVariable() const {
getTag() == dwarf::DW_TAG_constant); getTag() == dwarf::DW_TAG_constant);
} }
/// isUnspecifiedParmeter - Return true if the specified tag is
/// DW_TAG_unspecified_parameters.
bool DIDescriptor::isUnspecifiedParameter() const {
return DbgNode && getTag() == dwarf::DW_TAG_unspecified_parameters;
}
/// isScope - Return true if the specified tag is one of the scope /// isScope - Return true if the specified tag is one of the scope
/// related tag. /// related tag.
bool DIDescriptor::isScope() const { bool DIDescriptor::isScope() const {
@ -459,7 +447,7 @@ bool DIType::Verify() const {
// FIXME: Sink this into the various subclass verifies. // FIXME: Sink this into the various subclass verifies.
uint16_t Tag = getTag(); uint16_t Tag = getTag();
if (!isBasicType() && !isTrivialType() && Tag != dwarf::DW_TAG_const_type && if (!isBasicType() && Tag != dwarf::DW_TAG_const_type &&
Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type && Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type &&
Tag != dwarf::DW_TAG_ptr_to_member_type && Tag != dwarf::DW_TAG_ptr_to_member_type &&
Tag != dwarf::DW_TAG_reference_type && Tag != dwarf::DW_TAG_reference_type &&
@ -474,8 +462,6 @@ bool DIType::Verify() const {
// a CompositeType. // a CompositeType.
if (isBasicType()) if (isBasicType())
return DIBasicType(DbgNode).Verify(); return DIBasicType(DbgNode).Verify();
else if (isTrivialType())
return DITrivialType(DbgNode).Verify();
else if (isCompositeType()) else if (isCompositeType())
return DICompositeType(DbgNode).Verify(); return DICompositeType(DbgNode).Verify();
else if (isDerivedType()) else if (isDerivedType())
@ -489,10 +475,6 @@ bool DIBasicType::Verify() const {
return isBasicType() && DbgNode->getNumOperands() == 10; return isBasicType() && DbgNode->getNumOperands() == 10;
} }
bool DITrivialType::Verify() const {
return isTrivialType() && DbgNode->getNumOperands() == 1;
}
/// Verify - Verify that a derived type descriptor is well formed. /// Verify - Verify that a derived type descriptor is well formed.
bool DIDerivedType::Verify() const { bool DIDerivedType::Verify() const {
// Make sure DerivedFrom @ field 9 is TypeRef. // Make sure DerivedFrom @ field 9 is TypeRef.
@ -1297,7 +1279,7 @@ void DIEnumerator::printInternal(raw_ostream &OS) const {
} }
void DIType::printInternal(raw_ostream &OS) const { void DIType::printInternal(raw_ostream &OS) const {
if (!DbgNode || isTrivialType()) if (!DbgNode)
return; return;
StringRef Res = getName(); StringRef Res = getName();

View File

@ -76,16 +76,15 @@ attributes #1 = { nounwind readnone }
!5 = metadata !{metadata !6} !5 = metadata !{metadata !6}
!6 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"a", metadata !"a", metadata !"_ZN1A1aEiz", i32 6, metadata !7, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !12, i32 6} ; [ DW_TAG_subprogram ] [line 6] [a] !6 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"a", metadata !"a", metadata !"_ZN1A1aEiz", i32 6, metadata !7, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !12, i32 6} ; [ DW_TAG_subprogram ] [line 6] [a]
!7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!8 = metadata !{null, metadata !9, metadata !10, metadata !11} !8 = metadata !{null, metadata !9, metadata !10, null}
!9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A] !9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A]
!10 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] !10 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
!11 = metadata !{i32 786456}
!12 = metadata !{i32 786468} !12 = metadata !{i32 786468}
!13 = metadata !{metadata !14} !13 = metadata !{metadata !14}
!14 = metadata !{i32 786478, metadata !1, metadata !15, metadata !"b", metadata !"b", metadata !"_Z1biz", i32 13, metadata !16, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32, ...)* @_Z1biz, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 13] [def] [b] !14 = metadata !{i32 786478, metadata !1, metadata !15, metadata !"b", metadata !"b", metadata !"_Z1biz", i32 13, metadata !16, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32, ...)* @_Z1biz, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 13] [def] [b]
!15 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp] !15 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp]
!16 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !17, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !16 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !17, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!17 = metadata !{null, metadata !10, metadata !11} !17 = metadata !{null, metadata !10, null}
!18 = metadata !{i32 2, metadata !"Dwarf Version", i32 2} !18 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
!19 = metadata !{i32 1, metadata !"Debug Info Version", i32 1} !19 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
!20 = metadata !{metadata !"clang version 3.5 "} !20 = metadata !{metadata !"clang version 3.5 "}