Skip to content

Commit 2de4dbb

Browse files
committed
Merge pull request swiftlang#2084 from eeckstein/remove_from_parent
Remove removeFromParent
2 parents 4586af0 + f2036fc commit 2de4dbb

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

include/swift/SIL/SILBasicBlock.h

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
7474
/// This method unlinks 'self' from the containing SILFunction and deletes it.
7575
void eraseFromParent();
7676

77-
/// This method unlinks 'self' from the containing SILFunction.
78-
void removeFromParent();
79-
8077
/// Returns true if this BB is the entry BB of its parent.
8178
bool isEntry() const;
8279

lib/SIL/SILBasicBlock.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ void SILBasicBlock::eraseFromParent() {
103103
getParent()->getBlocks().erase(this);
104104
}
105105

106-
/// This method unlinks 'self' from the containing SILFunction.
107-
void SILBasicBlock::removeFromParent() {
108-
getParent()->getBlocks().remove(this);
109-
}
110-
111-
112106
/// Replace the ith BB argument with a new one with type Ty (and optional
113107
/// ValueDecl D).
114108
SILArgument *SILBasicBlock::replaceBBArg(unsigned i, SILType Ty,

lib/SILOptimizer/Transforms/SpeculativeDevirtualizer.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,19 @@ static FullApplySite speculateMonomorphicTarget(FullApplySite AI,
153153
}
154154

155155
// Remove the old Apply instruction.
156-
if (!isa<TryApplyInst>(AI))
156+
assert(AI.getInstruction() == &Continue->front() &&
157+
"AI should be the first instruction in the split Continue block");
158+
if (!isa<TryApplyInst>(AI)) {
157159
AI.getInstruction()->replaceAllUsesWith(Arg);
158-
auto *OriginalBB = AI.getParent();
159-
AI.getInstruction()->eraseFromParent();
160-
if (OriginalBB->empty())
161-
OriginalBB->removeFromParent();
160+
AI.getInstruction()->eraseFromParent();
161+
assert(!Continue->empty() &&
162+
"There should be at least a terminator after AI");
163+
} else {
164+
AI.getInstruction()->eraseFromParent();
165+
assert(Continue->empty() &&
166+
"There should not be an instruction after try_apply");
167+
Continue->eraseFromParent();
168+
}
162169

163170
// Update the stats.
164171
NumTargetsPredicted++;

0 commit comments

Comments
 (0)