[llvm] 5d3332b - [DWARFLinker] Use union to reduce sizeof(WorklistItem) (NFC)
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 23:24:48 PST 2020
Author: Jonas Devlieghere
Date: 2020-11-06T23:24:41-08:00
New Revision: 5d3332bc3ce2de80c68f4d63a7204e3f5803523b
URL: https://github.com/llvm/llvm-project/commit/5d3332bc3ce2de80c68f4d63a7204e3f5803523b
DIFF: https://github.com/llvm/llvm-project/commit/5d3332bc3ce2de80c68f4d63a7204e3f5803523b.diff
LOG: [DWARFLinker] Use union to reduce sizeof(WorklistItem) (NFC)
Reduce the size of the WorklistItem struct by using a struct.
Added:
Modified:
llvm/include/llvm/DWARFLinker/DWARFLinker.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
index 2fb61b9edf55..a96f403f6811 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
@@ -353,24 +353,26 @@ class DWARFLinker {
/// of work needs to be performed when processing the current item. The flags
/// and info fields are optional based on the type.
struct WorklistItem {
- WorklistItemType Type;
DWARFDie Die;
+ WorklistItemType Type;
CompileUnit &CU;
unsigned Flags;
- unsigned AncestorIdx = 0;
- CompileUnit::DIEInfo *OtherInfo = nullptr;
+ union {
+ const unsigned AncestorIdx;
+ CompileUnit::DIEInfo *OtherInfo;
+ };
WorklistItem(DWARFDie Die, CompileUnit &CU, unsigned Flags,
WorklistItemType T = WorklistItemType::LookForDIEsToKeep)
- : Type(T), Die(Die), CU(CU), Flags(Flags) {}
+ : Die(Die), Type(T), CU(CU), Flags(Flags), AncestorIdx(0) {}
WorklistItem(DWARFDie Die, CompileUnit &CU, WorklistItemType T,
CompileUnit::DIEInfo *OtherInfo = nullptr)
- : Type(T), Die(Die), CU(CU), OtherInfo(OtherInfo) {}
+ : Die(Die), Type(T), CU(CU), Flags(0), OtherInfo(OtherInfo) {}
WorklistItem(unsigned AncestorIdx, CompileUnit &CU, unsigned Flags)
- : Type(WorklistItemType::LookForParentDIEsToKeep), CU(CU), Flags(Flags),
- AncestorIdx(AncestorIdx) {}
+ : Die(), Type(WorklistItemType::LookForParentDIEsToKeep), CU(CU),
+ Flags(Flags), AncestorIdx(AncestorIdx) {}
};
/// returns true if we need to translate strings.
More information about the llvm-commits
mailing list