mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Solidify the assumption that a DW_TAG_subprogram's type is a DW_TAG_subroutine_type
There were bits & pieces of code lying around that may've given the impression that debug info metadata supported the possibility that a subprogram's type could be specified by a non-subroutine type describing the return type of a void function. This support was incomplete & unnecessary. Asserts & API have been changed to make the desired usage more clear. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182532 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
62c320a755
commit
3d33184d9d
@ -505,7 +505,7 @@ namespace llvm {
|
|||||||
DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
|
DISubprogram createFunction(DIDescriptor Scope, StringRef Name,
|
||||||
StringRef LinkageName,
|
StringRef LinkageName,
|
||||||
DIFile File, unsigned LineNo,
|
DIFile File, unsigned LineNo,
|
||||||
DIType Ty, bool isLocalToUnit,
|
DICompositeType Ty, bool isLocalToUnit,
|
||||||
bool isDefinition,
|
bool isDefinition,
|
||||||
unsigned ScopeLine,
|
unsigned ScopeLine,
|
||||||
unsigned Flags = 0,
|
unsigned Flags = 0,
|
||||||
@ -536,7 +536,7 @@ namespace llvm {
|
|||||||
DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
|
DISubprogram createMethod(DIDescriptor Scope, StringRef Name,
|
||||||
StringRef LinkageName,
|
StringRef LinkageName,
|
||||||
DIFile File, unsigned LineNo,
|
DIFile File, unsigned LineNo,
|
||||||
DIType Ty, bool isLocalToUnit,
|
DICompositeType Ty, bool isLocalToUnit,
|
||||||
bool isDefinition,
|
bool isDefinition,
|
||||||
unsigned Virtuality = 0, unsigned VTableIndex = 0,
|
unsigned Virtuality = 0, unsigned VTableIndex = 0,
|
||||||
MDNode *VTableHolder = 0,
|
MDNode *VTableHolder = 0,
|
||||||
|
@ -427,19 +427,6 @@ namespace llvm {
|
|||||||
unsigned getLineNumber() const { return getUnsignedField(6); }
|
unsigned getLineNumber() const { return getUnsignedField(6); }
|
||||||
DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
|
DICompositeType getType() const { return getFieldAs<DICompositeType>(7); }
|
||||||
|
|
||||||
/// getReturnTypeName - Subprogram return types are encoded either as
|
|
||||||
/// DIType or as DICompositeType.
|
|
||||||
StringRef getReturnTypeName() const {
|
|
||||||
DICompositeType DCT(getFieldAs<DICompositeType>(7));
|
|
||||||
if (DCT.Verify()) {
|
|
||||||
DIArray A = DCT.getTypeArray();
|
|
||||||
DIType T(A.getElement(0));
|
|
||||||
return T.getName();
|
|
||||||
}
|
|
||||||
DIType T(getFieldAs<DIType>(7));
|
|
||||||
return T.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// isLocalToUnit - Return true if this subprogram is local to the current
|
/// isLocalToUnit - Return true if this subprogram is local to the current
|
||||||
/// compile unit, like 'static' in C.
|
/// compile unit, like 'static' in C.
|
||||||
unsigned isLocalToUnit() const { return getUnsignedField(8); }
|
unsigned isLocalToUnit() const { return getUnsignedField(8); }
|
||||||
|
@ -1208,13 +1208,11 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
|
|||||||
|
|
||||||
// Add Return Type.
|
// Add Return Type.
|
||||||
DICompositeType SPTy = SP.getType();
|
DICompositeType SPTy = SP.getType();
|
||||||
DIArray Args = SPTy.getTypeArray();
|
assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
|
||||||
unsigned SPTag = SPTy.getTag();
|
"the type of a subprogram should be a subroutine");
|
||||||
|
|
||||||
if (Args.getNumElements() == 0 || SPTag != dwarf::DW_TAG_subroutine_type)
|
DIArray Args = SPTy.getTypeArray();
|
||||||
addType(SPDie, SPTy);
|
addType(SPDie, DIType(Args.getElement(0)));
|
||||||
else
|
|
||||||
addType(SPDie, DIType(Args.getElement(0)));
|
|
||||||
|
|
||||||
unsigned VK = SP.getVirtuality();
|
unsigned VK = SP.getVirtuality();
|
||||||
if (VK) {
|
if (VK) {
|
||||||
@ -1232,19 +1230,14 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
|
|||||||
|
|
||||||
// Add arguments. Do not add arguments for subprogram definition. They will
|
// Add arguments. Do not add arguments for subprogram definition. They will
|
||||||
// be handled while processing variables.
|
// be handled while processing variables.
|
||||||
DICompositeType SPTy = SP.getType();
|
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
|
||||||
DIArray Args = SPTy.getTypeArray();
|
DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
|
||||||
unsigned SPTag = SPTy.getTag();
|
DIType ATy = DIType(Args.getElement(i));
|
||||||
|
addType(Arg, ATy);
|
||||||
if (SPTag == dwarf::DW_TAG_subroutine_type)
|
if (ATy.isArtificial())
|
||||||
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
|
addFlag(Arg, dwarf::DW_AT_artificial);
|
||||||
DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
|
SPDie->addChild(Arg);
|
||||||
DIType ATy = DIType(Args.getElement(i));
|
}
|
||||||
addType(Arg, ATy);
|
|
||||||
if (ATy.isArtificial())
|
|
||||||
addFlag(Arg, dwarf::DW_AT_artificial);
|
|
||||||
SPDie->addChild(Arg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SP.isArtificial())
|
if (SP.isArtificial())
|
||||||
|
@ -969,13 +969,15 @@ DISubprogram DIBuilder::createFunction(DIDescriptor Context,
|
|||||||
StringRef Name,
|
StringRef Name,
|
||||||
StringRef LinkageName,
|
StringRef LinkageName,
|
||||||
DIFile File, unsigned LineNo,
|
DIFile File, unsigned LineNo,
|
||||||
DIType Ty,
|
DICompositeType Ty,
|
||||||
bool isLocalToUnit, bool isDefinition,
|
bool isLocalToUnit, bool isDefinition,
|
||||||
unsigned ScopeLine,
|
unsigned ScopeLine,
|
||||||
unsigned Flags, bool isOptimized,
|
unsigned Flags, bool isOptimized,
|
||||||
Function *Fn,
|
Function *Fn,
|
||||||
MDNode *TParams,
|
MDNode *TParams,
|
||||||
MDNode *Decl) {
|
MDNode *Decl) {
|
||||||
|
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
||||||
|
"function types should be subroutines");
|
||||||
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
||||||
Value *Elts[] = {
|
Value *Elts[] = {
|
||||||
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
||||||
@ -1014,7 +1016,7 @@ DISubprogram DIBuilder::createMethod(DIDescriptor Context,
|
|||||||
StringRef Name,
|
StringRef Name,
|
||||||
StringRef LinkageName,
|
StringRef LinkageName,
|
||||||
DIFile F,
|
DIFile F,
|
||||||
unsigned LineNo, DIType Ty,
|
unsigned LineNo, DICompositeType Ty,
|
||||||
bool isLocalToUnit,
|
bool isLocalToUnit,
|
||||||
bool isDefinition,
|
bool isDefinition,
|
||||||
unsigned VK, unsigned VIndex,
|
unsigned VK, unsigned VIndex,
|
||||||
@ -1023,6 +1025,8 @@ DISubprogram DIBuilder::createMethod(DIDescriptor Context,
|
|||||||
bool isOptimized,
|
bool isOptimized,
|
||||||
Function *Fn,
|
Function *Fn,
|
||||||
MDNode *TParam) {
|
MDNode *TParam) {
|
||||||
|
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
||||||
|
"function types should be subroutines");
|
||||||
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
||||||
Value *Elts[] = {
|
Value *Elts[] = {
|
||||||
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
||||||
|
@ -18,12 +18,13 @@ entry:
|
|||||||
!1 = metadata !{i32 0}
|
!1 = metadata !{i32 0}
|
||||||
!3 = metadata !{metadata !5, metadata !12}
|
!3 = metadata !{metadata !5, metadata !12}
|
||||||
!5 = metadata !{i32 786478, metadata !"_Z1qv", i32 0, metadata !6, metadata !"q", metadata !"q", metadata !6, i32 5, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1qv, null, null, metadata !10} ; [ DW_TAG_subprogram ]
|
!5 = metadata !{i32 786478, metadata !"_Z1qv", i32 0, metadata !6, metadata !"q", metadata !"q", metadata !6, i32 5, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1qv, null, null, metadata !10} ; [ DW_TAG_subprogram ]
|
||||||
!6 = metadata !{i32 786473, metadata !"foo.cpp", metadata !"/Users/echristo/tmp", null} ; [ DW_TAG_file_type ]
|
!6 = metadata !{i32 786473, metadata !15} ; [ DW_TAG_file_type ]
|
||||||
!7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
|
!7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
|
||||||
!8 = metadata !{metadata !9}
|
!8 = metadata !{metadata !9}
|
||||||
!9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
!9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||||
!10 = metadata !{metadata !11}
|
!10 = metadata !{metadata !11}
|
||||||
!11 = metadata !{i32 786468} ; [ DW_TAG_base_type ]
|
!11 = metadata !{i32 786468} ; [ DW_TAG_base_type ]
|
||||||
!12 = metadata !{i32 786478, metadata !"", i32 0, metadata !6, metadata !"t", metadata !"t", metadata !6, i32 2, metadata !7, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, null, null, null, metadata !10} ; [ DW_TAG_subprogram ]
|
!12 = metadata !{i32 786478, metadata !15, metadata !6, metadata !"t", metadata !"t", metadata !"", i32 2, metadata !7, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, null, null, null, metadata !10} ; [ DW_TAG_subprogram ]
|
||||||
!13 = metadata !{i32 7, i32 1, metadata !14, null}
|
!13 = metadata !{i32 7, i32 1, metadata !14, null}
|
||||||
!14 = metadata !{i32 786443, metadata !5, i32 5, i32 1, metadata !6, i32 0} ; [ DW_TAG_lexical_block ]
|
!14 = metadata !{i32 786443, metadata !5, i32 5, i32 1, metadata !6, i32 0} ; [ DW_TAG_lexical_block ]
|
||||||
|
!15 = metadata !{metadata !"foo.cpp", metadata !"/Users/echristo/tmp"}
|
||||||
|
Loading…
Reference in New Issue
Block a user