Skip to content

Commit 7b7ccdc

Browse files
committed
[pmo] Eliminate more dead code.
1 parent 7175e17 commit 7b7ccdc

File tree

2 files changed

+1
-98
lines changed

2 files changed

+1
-98
lines changed

lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,9 @@
2323
using namespace swift;
2424

2525
//===----------------------------------------------------------------------===//
26-
// PMOMemoryObjectInfo Implementation
26+
// PMOMemoryObjectInfo Implementation
2727
//===----------------------------------------------------------------------===//
2828

29-
static unsigned getElementCountRec(SILModule &Module, SILType T) {
30-
// If this is a tuple, it is always recursively flattened.
31-
if (CanTupleType TT = T.getAs<TupleType>()) {
32-
unsigned NumElements = 0;
33-
for (unsigned i = 0, e = TT->getNumElements(); i < e; i++)
34-
NumElements += getElementCountRec(Module, T.getTupleElementType(i));
35-
return NumElements;
36-
}
37-
38-
// Otherwise, it is a single element.
39-
return 1;
40-
}
41-
4229
PMOMemoryObjectInfo::PMOMemoryObjectInfo(AllocationInst *allocation)
4330
: MemoryInst(allocation) {
4431
auto &module = MemoryInst->getModule();
@@ -57,81 +44,6 @@ SILInstruction *PMOMemoryObjectInfo::getFunctionEntryPoint() const {
5744
return &*getFunction().begin()->begin();
5845
}
5946

60-
/// Given a symbolic element number, return the type of the element.
61-
static SILType getElementTypeRec(SILModule &Module, SILType T, unsigned EltNo) {
62-
// If this is a tuple type, walk into it.
63-
if (CanTupleType TT = T.getAs<TupleType>()) {
64-
for (unsigned i = 0, e = TT->getNumElements(); i < e; i++) {
65-
auto FieldType = T.getTupleElementType(i);
66-
unsigned NumFieldElements = getElementCountRec(Module, FieldType);
67-
if (EltNo < NumFieldElements)
68-
return getElementTypeRec(Module, FieldType, EltNo);
69-
EltNo -= NumFieldElements;
70-
}
71-
// This can only happen if we look at a symbolic element number of an empty
72-
// tuple.
73-
llvm::report_fatal_error("invalid element number");
74-
}
75-
76-
// Otherwise, it is a leaf element.
77-
assert(EltNo == 0);
78-
return T;
79-
}
80-
81-
/// getElementTypeRec - Return the swift type of the specified element.
82-
SILType PMOMemoryObjectInfo::getElementType(unsigned EltNo) const {
83-
auto &Module = MemoryInst->getModule();
84-
return getElementTypeRec(Module, MemorySILType, EltNo);
85-
}
86-
87-
/// Push the symbolic path name to the specified element number onto the
88-
/// specified std::string.
89-
static void getPathStringToElementRec(SILModule &Module, SILType T,
90-
unsigned EltNo, std::string &Result) {
91-
if (CanTupleType TT = T.getAs<TupleType>()) {
92-
unsigned FieldNo = 0;
93-
for (unsigned i = 0, e = TT->getNumElements(); i < e; i++) {
94-
auto Field = TT->getElement(i);
95-
SILType FieldTy = T.getTupleElementType(i);
96-
unsigned NumFieldElements = getElementCountRec(Module, FieldTy);
97-
98-
if (EltNo < NumFieldElements) {
99-
Result += '.';
100-
if (Field.hasName())
101-
Result += Field.getName().str();
102-
else
103-
Result += llvm::utostr(FieldNo);
104-
return getPathStringToElementRec(Module, FieldTy, EltNo, Result);
105-
}
106-
107-
EltNo -= NumFieldElements;
108-
109-
++FieldNo;
110-
}
111-
llvm_unreachable("Element number is out of range for this type!");
112-
}
113-
114-
// Otherwise, there are no subelements.
115-
assert(EltNo == 0 && "Element count problem");
116-
}
117-
118-
ValueDecl *
119-
PMOMemoryObjectInfo::getPathStringToElement(unsigned Element,
120-
std::string &Result) const {
121-
auto &Module = MemoryInst->getModule();
122-
123-
if (auto *VD = dyn_cast_or_null<ValueDecl>(getLoc().getAsASTNode<Decl>()))
124-
Result = VD->getBaseName().userFacingName();
125-
else
126-
Result = "<unknown>";
127-
128-
// Get the path through a tuple, if relevant.
129-
getPathStringToElementRec(Module, MemorySILType, Element, Result);
130-
131-
// Otherwise, we can't.
132-
return nullptr;
133-
}
134-
13547
//===----------------------------------------------------------------------===//
13648
// Scalarization Logic
13749
//===----------------------------------------------------------------------===//

lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,6 @@ class PMOMemoryObjectInfo {
9898
AllocBoxInst *getContainer() const {
9999
return dyn_cast<AllocBoxInst>(MemoryInst);
100100
}
101-
102-
/// getElementType - Return the swift type of the specified element.
103-
SILType getElementType(unsigned EltNo) const;
104-
105-
/// Push the symbolic path name to the specified element number onto the
106-
/// specified std::string. If the actual decl (or a subelement thereof) can
107-
/// be determined, return it. Otherwise, return null.
108-
ValueDecl *getPathStringToElement(unsigned Element,
109-
std::string &Result) const;
110101
};
111102

112103
enum PMOUseKind {

0 commit comments

Comments
 (0)