[llvm] 3897137 - [DWARFLinker] Add CompileUnit::getInfo helper that takes a DWARFDie (NFC)
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 19:37:51 PST 2020
Author: Jonas Devlieghere
Date: 2020-11-06T19:37:44-08:00
New Revision: 3897137598128e64c246a6a604f948fa4e9a5db7
URL: https://github.com/llvm/llvm-project/commit/3897137598128e64c246a6a604f948fa4e9a5db7
DIFF: https://github.com/llvm/llvm-project/commit/3897137598128e64c246a6a604f948fa4e9a5db7.diff
LOG: [DWARFLinker] Add CompileUnit::getInfo helper that takes a DWARFDie (NFC)
Eliminate the need to go through the DIE index by passing the DIE to
CompileUnit::getInfo directly.
Before:
unsigned Idx = Unit->getOrigUnit().getDIEIndex(Die);
CompileUnit::DIEInfo &Info = Unit->getInfo(Idx);
After:
CompileUnit::DIEInfo &Info = Unit->getInfo(Die);
Added:
Modified:
llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
llvm/lib/DWARFLinker/DWARFLinker.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
index 6c1649a68f3f1..740b1293f6186 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h
@@ -120,6 +120,11 @@ class CompileUnit {
DIEInfo &getInfo(unsigned Idx) { return Info[Idx]; }
const DIEInfo &getInfo(unsigned Idx) const { return Info[Idx]; }
+ DIEInfo &getInfo(const DWARFDie &Die) {
+ unsigned Idx = getOrigUnit().getDIEIndex(Die);
+ return Info[Idx];
+ }
+
uint64_t getStartOffset() const { return StartOffset; }
uint64_t getNextUnitOffset() const { return NextUnitOffset; }
void setStartOffset(uint64_t DebugInfoSize) { StartOffset = DebugInfoSize; }
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 2b12274281055..dc26844a0b39b 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -522,8 +522,7 @@ static void updateChildIncompleteness(const DWARFDie &Die, CompileUnit &CU,
return;
}
- unsigned Idx = CU.getOrigUnit().getDIEIndex(Die);
- CompileUnit::DIEInfo &MyInfo = CU.getInfo(Idx);
+ CompileUnit::DIEInfo &MyInfo = CU.getInfo(Die);
if (ChildInfo.Incomplete || ChildInfo.Prune)
MyInfo.Incomplete = true;
@@ -545,8 +544,7 @@ static void updateRefIncompleteness(const DWARFDie &Die, CompileUnit &CU,
return;
}
- unsigned Idx = CU.getOrigUnit().getDIEIndex(Die);
- CompileUnit::DIEInfo &MyInfo = CU.getInfo(Idx);
+ CompileUnit::DIEInfo &MyInfo = CU.getInfo(Die);
if (MyInfo.Incomplete)
return;
@@ -578,8 +576,7 @@ void DWARFLinker::lookForChildDIEsToKeep(
for (auto Child : reverse(Die.children())) {
// Add a worklist item before every child to calculate incompleteness right
// after the current child is processed.
- unsigned Idx = CU.getOrigUnit().getDIEIndex(Child);
- CompileUnit::DIEInfo &ChildInfo = CU.getInfo(Idx);
+ CompileUnit::DIEInfo &ChildInfo = CU.getInfo(Child);
Worklist.emplace_back(Die, CU, WorklistItemType::UpdateChildIncompleteness,
&ChildInfo);
Worklist.emplace_back(Child, CU, Flags);
@@ -614,8 +611,7 @@ void DWARFLinker::lookForRefDIEsToKeep(
CompileUnit *ReferencedCU;
if (auto RefDie =
resolveDIEReference(File, Units, Val, Die, ReferencedCU)) {
- uint32_t RefIdx = ReferencedCU->getOrigUnit().getDIEIndex(RefDie);
- CompileUnit::DIEInfo &Info = ReferencedCU->getInfo(RefIdx);
+ CompileUnit::DIEInfo &Info = ReferencedCU->getInfo(RefDie);
bool IsModuleRef = Info.Ctxt && Info.Ctxt->getCanonicalDIEOffset() &&
Info.Ctxt->isDefinedInClangModule();
// If the referenced DIE has a DeclContext that has already been
@@ -649,8 +645,7 @@ void DWARFLinker::lookForRefDIEsToKeep(
for (auto &P : reverse(ReferencedDIEs)) {
// Add a worklist item before every child to calculate incompleteness right
// after the current child is processed.
- uint32_t RefIdx = P.second.getOrigUnit().getDIEIndex(P.first);
- CompileUnit::DIEInfo &Info = P.second.getInfo(RefIdx);
+ CompileUnit::DIEInfo &Info = P.second.getInfo(P.first);
Worklist.emplace_back(Die, CU, WorklistItemType::UpdateRefIncompleteness,
&Info);
Worklist.emplace_back(P.first, P.second,
@@ -854,8 +849,7 @@ unsigned DWARFLinker::DIECloner::cloneDieReferenceAttribute(
if (!RefDie || AttrSpec.Attr == dwarf::DW_AT_sibling)
return 0;
- unsigned Idx = RefUnit->getOrigUnit().getDIEIndex(RefDie);
- CompileUnit::DIEInfo &RefInfo = RefUnit->getInfo(Idx);
+ CompileUnit::DIEInfo &RefInfo = RefUnit->getInfo(RefDie);
// If we already have emitted an equivalent DeclContext, just point
// at it.
@@ -947,8 +941,7 @@ void DWARFLinker::DIECloner::cloneExpression(
// DW_OP_reinterpret, which is currently not supported.
if (RefOffset > 0 || Op.getCode() != dwarf::DW_OP_convert) {
auto RefDie = Unit.getOrigUnit().getDIEForOffset(RefOffset);
- uint32_t RefIdx = Unit.getOrigUnit().getDIEIndex(RefDie);
- CompileUnit::DIEInfo &Info = Unit.getInfo(RefIdx);
+ CompileUnit::DIEInfo &Info = Unit.getInfo(RefDie);
if (DIE *Clone = Info.Clone)
Offset = Clone->getOffset();
else
More information about the llvm-commits
mailing list