Skip to content

Commit 8277793

Browse files
committed
SILOptimzer: add a workaround to repair the Windows builds
The current implementation of `InstModCallbacks` seems to fail to invoke the `eraseFromParent` on the instruction when performing GlobalOpt. As a result, we end up with undefined references that are preserved. This workaround ensures that the instruction is removed. This should allow us to finally refresh the Windows toolchain.
1 parent bf84d8d commit 8277793

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/SILOptimizer/IPO/GlobalOpt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,12 @@ replaceLoadsByKnownValue(SILFunction *InitF, SILGlobalVariable *SILG,
399399
replaceLoadsFromGlobal(initCall, initVal, cloner);
400400

401401
// Remove all instructions which are dead now.
402-
InstructionDeleter deleter;
402+
InstructionDeleter deleter(
403+
InstModCallbacks()
404+
.onDelete([](SILInstruction *I) { I->eraseFromParent(); })
405+
);
403406
deleter.recursivelyDeleteUsersIfDead(initCall);
407+
404408
if (initCall->use_empty()) {
405409
// The call to the addressor is dead as well and can be removed.
406410
auto *callee = dyn_cast<FunctionRefInst>(initCall->getCallee());

lib/SILOptimizer/Transforms/CSE.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,10 @@ bool CSE::processLazyPropertyGetters() {
725725
SILBasicBlock *callBlock = ai->getParent();
726726

727727
// Inline the getter...
728-
InstructionDeleter deleter;
728+
InstructionDeleter deleter(
729+
InstModCallbacks()
730+
.onDelete([](SILInstruction *I) { I->eraseFromParent(); })
731+
);
729732
SILInliner::inlineFullApply(ai, SILInliner::InlineKind::PerformanceInline,
730733
FuncBuilder, deleter);
731734
deleter.cleanupDeadInstructions();

0 commit comments

Comments
 (0)