Skip to content

Commit 7fb871a

Browse files
committed
Disable dead conformance elimination for now.
There are still several open issues (e.g. asserts in IRGen) and it seems to be hard to fix them. Most likely we’ll go for a different approach at all.
1 parent 23b216b commit 7fb871a

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

include/swift/SIL/InstructionUtils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ class ConformanceCollector {
123123

124124
ConformanceCollector(SILModule &M) : M(M) { }
125125

126+
#ifndef NDEBUG
127+
static bool verifyInIRGen() {
128+
// TODO: currently disabled because of several problems.
129+
return false;
130+
}
131+
#endif
132+
126133
/// Collect all used conformances of an instruction.
127134
///
128135
/// If the instruction can escape a metatype, also record this metatype.

lib/IRGen/GenDecl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,9 @@ IRGenModule::getAddrOfLLVMVariable(LinkEntity entity, Alignment alignment,
18561856

18571857
void IRGenModule::checkEligibleConf(const ProtocolConformance *Conf) {
18581858
#ifndef NDEBUG
1859+
if (!ConformanceCollector::verifyInIRGen())
1860+
return;
1861+
18591862
if (EligibleConfs.isUsed(Conf))
18601863
return;
18611864

@@ -1876,6 +1879,9 @@ void IRGenModule::checkEligibleConf(const ProtocolConformance *Conf) {
18761879

18771880
void IRGenModule::checkEligibleMetaType(NominalTypeDecl *NT) {
18781881
#ifndef NDEBUG
1882+
if (!ConformanceCollector::verifyInIRGen())
1883+
return;
1884+
18791885
if (!NT || EligibleConfs.isMetaTypeEscaping(NT))
18801886
return;
18811887

lib/SILOptimizer/IPO/DeadFunctionElimination.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ using namespace swift;
2828
STATISTIC(NumDeadFunc, "Number of dead functions eliminated");
2929
STATISTIC(NumEliminatedExternalDefs, "Number of external function definitions eliminated");
3030

31+
llvm::cl::opt<bool> RemoveDeadConformances(
32+
"remove-dead-conformances", llvm::cl::init(false),
33+
llvm::cl::desc("Remove dead conformances"));
34+
3135
namespace {
3236

3337
/// This is a base class for passes that are based on function liveness
@@ -318,7 +322,8 @@ class FunctionLivenessComputation {
318322
} else if (auto *FRI = dyn_cast<FunctionRefInst>(&I)) {
319323
ensureAlive(FRI->getReferencedFunction());
320324
}
321-
FoundConformances.collect(&I);
325+
if (RemoveDeadConformances)
326+
FoundConformances.collect(&I);
322327
}
323328
}
324329
// Now we scan all _new_ conformances we found in the function.
@@ -546,7 +551,7 @@ class DeadFunctionElimination : FunctionLivenessComputation {
546551

547552
ProtocolConformance *C = WT.getConformance();
548553
CanType ConformingTy = C->getType()->getCanonicalType();
549-
if (ConformingTy.isAnyClassReferenceType()) {
554+
if (!RemoveDeadConformances || ConformingTy.isAnyClassReferenceType()) {
550555
// We are very conservative with class conformances. Even if a private/
551556
// internal class is never instantiated, it might be created via
552557
// reflection by using the stdlib's _getTypeByMangledName function.

test/SILOptimizer/dead_conformance.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -sil-deadfuncelim %s | %FileCheck %s
1+
// RUN: %target-sil-opt -remove-dead-conformances -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -sil-deadfuncelim %s | %FileCheck %s
22

33
sil_stage canonical
44

0 commit comments

Comments
 (0)