Skip to content

Commit 9dd7074

Browse files
committed
[sil-func-extractor] Rather than manually creating a pass manager just to run DFE, just
add a high level API to perform the operation.
1 parent ef94156 commit 9dd7074

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

include/swift/SILOptimizer/PassManager/Passes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ namespace swift {
4444
/// user code.
4545
void performSILDiagnoseUnreachable(SILModule *M);
4646

47+
/// \brief Remove dead functions from \p M.
48+
void performSILDeadFunctionElimination(SILModule *M);
49+
4750
/// \brief Link a SILFunction declaration to the actual definition in the
4851
/// serialized modules.
4952
///

lib/SILOptimizer/IPO/DeadFunctionElimination.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,3 +604,9 @@ SILTransform *swift::createDeadFunctionElimination() {
604604
SILTransform *swift::createExternalFunctionDefinitionsElimination() {
605605
return new SILExternalFuncDefinitionsElimination();
606606
}
607+
608+
void swift::performSILDeadFunctionElimination(SILModule *M) {
609+
SILPassManager PM(M, "SIL Dead Function Elimination");
610+
PM.addDeadFunctionElimination();
611+
PM.runOneIteration();
612+
}

tools/sil-func-extractor/SILFunctionExtractor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ void removeUnwantedFunctions(SILModule *M, ArrayRef<std::string> MangledNames,
215215
}
216216

217217
// Remove dead functions.
218-
SILPassManager PM(M);
219-
PM.addDeadFunctionElimination();
220-
PM.run();
218+
performSILDeadFunctionElimination(M);
221219
}
222220

223221
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)