Skip to content

Remove removeFromParent #2084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions include/swift/SIL/SILBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
/// This method unlinks 'self' from the containing SILFunction and deletes it.
void eraseFromParent();

/// This method unlinks 'self' from the containing SILFunction.
void removeFromParent();

/// Returns true if this BB is the entry BB of its parent.
bool isEntry() const;

Expand Down
6 changes: 0 additions & 6 deletions lib/SIL/SILBasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ void SILBasicBlock::eraseFromParent() {
getParent()->getBlocks().erase(this);
}

/// This method unlinks 'self' from the containing SILFunction.
void SILBasicBlock::removeFromParent() {
getParent()->getBlocks().remove(this);
}


/// Replace the ith BB argument with a new one with type Ty (and optional
/// ValueDecl D).
SILArgument *SILBasicBlock::replaceBBArg(unsigned i, SILType Ty,
Expand Down
17 changes: 12 additions & 5 deletions lib/SILOptimizer/Transforms/SpeculativeDevirtualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,19 @@ static FullApplySite speculateMonomorphicTarget(FullApplySite AI,
}

// Remove the old Apply instruction.
if (!isa<TryApplyInst>(AI))
assert(AI.getInstruction() == &Continue->front() &&
"AI should be the first instruction in the split Continue block");
if (!isa<TryApplyInst>(AI)) {
AI.getInstruction()->replaceAllUsesWith(Arg);
auto *OriginalBB = AI.getParent();
AI.getInstruction()->eraseFromParent();
if (OriginalBB->empty())
OriginalBB->removeFromParent();
AI.getInstruction()->eraseFromParent();
assert(!Continue->empty() &&
"There should be at least a terminator after AI");
} else {
AI.getInstruction()->eraseFromParent();
assert(Continue->empty() &&
"There should not be an instruction after try_apply");
Continue->eraseFromParent();
}

// Update the stats.
NumTargetsPredicted++;
Expand Down