[llvm] r235349 - DwarfUnit: Split MDSubroutineType version of constructTypeDIE()
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 20 14:04:33 PDT 2015
Author: dexonsmith
Date: Mon Apr 20 16:04:33 2015
New Revision: 235349
URL: http://llvm.org/viewvc/llvm-project?rev=235349&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=235349&r1=235348&r2=235349&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Apr 20 16:04:33 2015
@@ -1961,7 +1961,7 @@ void DwarfDebug::addDwarfTypeUnitType(Dw
// 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;
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=235349&r1=235348&r2=235349&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Mon Apr 20 16:04:33 2015
@@ -727,7 +727,7 @@ DIE *DwarfUnit::createTypeDIE(DIComposit
// 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
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::constructSubprogramArgum
}
}
-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 &Bu
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: {
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=235349&r1=235348&r2=235349&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Mon Apr 20 16:04:33 2015
@@ -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);
More information about the llvm-commits
mailing list