Skip to content

Commit 3dfa2ce

Browse files
Xin TongXin Tong
Xin Tong
authored and
Xin Tong
committed
Revert "[sil-optimizer] Remove the opened archetypes related workarounds which are obsolete now."
This reverts commit 7868318. It is related to 8ef8bb4 which broke swift_tools-RA_stdlib-RD_test-no_device and some others.
1 parent f52555e commit 3dfa2ce

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: lib/SILOptimizer/LoopTransforms/LICM.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ static bool canHoistInstruction(SILInstruction *Inst, SILLoop *Loop,
231231
if (isa<AllocationInst>(Inst) || isa<DeallocStackInst>(Inst))
232232
return false;
233233

234+
// Can't hoist metatype instruction referring to an opened existential,
235+
// because it may break the dominance relationship.
236+
if (isa<MetatypeInst>(Inst) &&
237+
Inst->getType().getSwiftRValueType()->hasOpenedExistential()) {
238+
return false;
239+
}
240+
234241
// Can't hoist instructions which may have side effects.
235242
if (!hasNoSideEffect(Inst, SafeReads))
236243
return false;

Diff for: lib/SILOptimizer/Transforms/Sink.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ class CodeSinkingPass : public SILFunctionTransform {
6767
if (II->isAllocatingStack() || II->isDeallocatingStack())
6868
return false;
6969

70+
// We don't sink open_existential_* instructions, because
71+
// there may be some instructions depending on them, e.g.
72+
// metatype_inst, etc. But this kind of dependency
73+
// cannot be expressed in SIL yet.
74+
switch (II->getKind()) {
75+
default: break;
76+
case ValueKind::OpenExistentialBoxInst:
77+
case ValueKind::OpenExistentialRefInst:
78+
case ValueKind::OpenExistentialAddrInst:
79+
case ValueKind::OpenExistentialMetatypeInst:
80+
return false;
81+
}
82+
7083
SILBasicBlock *CurrentBlock = II->getParent();
7184
SILBasicBlock *Dest = nullptr;
7285
unsigned InitialLoopDepth = LoopInfo->getLoopDepth(CurrentBlock);

0 commit comments

Comments
 (0)