mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
DwarfUnit: Split MDSubroutineType version of constructTypeDIE()
The version of `constructTypeDIE()` for `MDSubroutineType` is unrelated to (and has different callers than) the `MDCompositeType`. Split the two in half. This simplifies an upcoming patch to delete `DICompositeType`. There shouldn't be any real functionality change here. `createTypeDIE()` is `cast<>`'ing where it didn't need to before, but that function in turn is only called for true `MDCompositeType`s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235349 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
302f000bf4
commit
80608c5d42
@ -1961,7 +1961,7 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
|
||||
// This is inefficient because all the dependent types will be rebuilt
|
||||
// from scratch, including building them in type units, discovering that
|
||||
// they depend on addresses, throwing them out and rebuilding them.
|
||||
CU.constructTypeDIE(RefDie, CTy);
|
||||
CU.constructTypeDIE(RefDie, cast<MDCompositeType>(CTy));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -727,7 +727,7 @@ DIE *DwarfUnit::createTypeDIE(DICompositeType Ty) {
|
||||
// Create new type.
|
||||
DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
|
||||
|
||||
constructTypeDIE(TyDIE, Ty);
|
||||
constructTypeDIE(TyDIE, cast<MDCompositeType>(Ty));
|
||||
|
||||
updateAcceleratorTables(Context, Ty, TyDIE);
|
||||
return &TyDIE;
|
||||
@ -762,7 +762,9 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
|
||||
|
||||
if (auto *BT = dyn_cast<MDBasicType>(Ty))
|
||||
constructTypeDIE(TyDIE, BT);
|
||||
else if (DICompositeType CTy = dyn_cast<MDCompositeTypeBase>(Ty)) {
|
||||
else if (auto *STy = dyn_cast<MDSubroutineType>(Ty))
|
||||
constructTypeDIE(TyDIE, STy);
|
||||
else if (auto *CTy = dyn_cast<MDCompositeType>(Ty)) {
|
||||
if (GenerateDwarfTypeUnits && !Ty->isForwardDecl())
|
||||
if (MDString *TypeId = CTy->getRawIdentifier()) {
|
||||
DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
|
||||
@ -913,7 +915,35 @@ void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) {
|
||||
}
|
||||
}
|
||||
|
||||
void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||
void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDSubroutineType *CTy) {
|
||||
// Add return type. A void return won't have a type.
|
||||
auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray();
|
||||
if (Elements.size())
|
||||
if (auto RTy = resolve(Elements[0]))
|
||||
addType(Buffer, RTy);
|
||||
|
||||
bool isPrototyped = true;
|
||||
if (Elements.size() == 2 && !Elements[1])
|
||||
isPrototyped = false;
|
||||
|
||||
constructSubprogramArguments(Buffer, Elements);
|
||||
|
||||
// Add prototype flag if we're dealing with a C language and the function has
|
||||
// been prototyped.
|
||||
uint16_t Language = getLanguage();
|
||||
if (isPrototyped &&
|
||||
(Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
|
||||
Language == dwarf::DW_LANG_ObjC))
|
||||
addFlag(Buffer, dwarf::DW_AT_prototyped);
|
||||
|
||||
if (CTy->isLValueReference())
|
||||
addFlag(Buffer, dwarf::DW_AT_reference);
|
||||
|
||||
if (CTy->isRValueReference())
|
||||
addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
|
||||
}
|
||||
|
||||
void DwarfUnit::constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy) {
|
||||
// Add name if not anonymous or intermediate type.
|
||||
StringRef Name = CTy->getName();
|
||||
|
||||
@ -927,33 +957,6 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||
case dwarf::DW_TAG_enumeration_type:
|
||||
constructEnumTypeDIE(Buffer, CTy);
|
||||
break;
|
||||
case dwarf::DW_TAG_subroutine_type: {
|
||||
// Add return type. A void return won't have a type.
|
||||
auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray();
|
||||
if (Elements.size())
|
||||
if (auto RTy = resolve(Elements[0]))
|
||||
addType(Buffer, RTy);
|
||||
|
||||
bool isPrototyped = true;
|
||||
if (Elements.size() == 2 && !Elements[1])
|
||||
isPrototyped = false;
|
||||
|
||||
constructSubprogramArguments(Buffer, Elements);
|
||||
|
||||
// Add prototype flag if we're dealing with a C language and the
|
||||
// function has been prototyped.
|
||||
uint16_t Language = getLanguage();
|
||||
if (isPrototyped &&
|
||||
(Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
|
||||
Language == dwarf::DW_LANG_ObjC))
|
||||
addFlag(Buffer, dwarf::DW_AT_prototyped);
|
||||
|
||||
if (CTy->isLValueReference())
|
||||
addFlag(Buffer, dwarf::DW_AT_reference);
|
||||
|
||||
if (CTy->isRValueReference())
|
||||
addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
|
||||
} break;
|
||||
case dwarf::DW_TAG_structure_type:
|
||||
case dwarf::DW_TAG_union_type:
|
||||
case dwarf::DW_TAG_class_type: {
|
||||
|
@ -335,7 +335,7 @@ public:
|
||||
|
||||
virtual DwarfCompileUnit &getCU() = 0;
|
||||
|
||||
void constructTypeDIE(DIE &Buffer, DICompositeType CTy);
|
||||
void constructTypeDIE(DIE &Buffer, const MDCompositeType *CTy);
|
||||
|
||||
protected:
|
||||
/// \brief Create new static data member DIE.
|
||||
@ -354,6 +354,7 @@ protected:
|
||||
private:
|
||||
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
|
||||
void constructTypeDIE(DIE &Buffer, DIDerivedType DTy);
|
||||
void constructTypeDIE(DIE &Buffer, const MDSubroutineType *DTy);
|
||||
void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
|
||||
void constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy);
|
||||
void constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy);
|
||||
|
Loading…
Reference in New Issue
Block a user