mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: fix APIs for (re)moving instructions
Instructions can only be moved and erased, but never _removed_ from a block.
This commit is contained in:
@@ -91,10 +91,6 @@ void SILBasicBlock::push_front(SILInstruction *I) {
|
||||
InstList.push_front(I);
|
||||
}
|
||||
|
||||
void SILBasicBlock::remove(SILInstruction *I) {
|
||||
InstList.remove(I);
|
||||
}
|
||||
|
||||
void SILBasicBlock::eraseAllInstructions(SILModule &module) {
|
||||
while (!empty()) {
|
||||
erase(&*begin(), module);
|
||||
@@ -112,6 +108,21 @@ void SILBasicBlock::erase(SILInstruction *I, SILModule &module) {
|
||||
module.scheduleForDeletion(I);
|
||||
}
|
||||
|
||||
void SILBasicBlock::moveInstruction(SILInstruction *inst,
|
||||
SILInstruction *beforeInst) {
|
||||
if (inst == beforeInst)
|
||||
return;
|
||||
inst->getParent()->InstList.remove(inst);
|
||||
inst->ParentBB = nullptr;
|
||||
beforeInst->getParent()->insert(beforeInst->getIterator(), inst);
|
||||
}
|
||||
|
||||
void SILBasicBlock::moveInstructionToFront(SILInstruction *inst) {
|
||||
inst->getParent()->InstList.remove(inst);
|
||||
inst->ParentBB = nullptr;
|
||||
push_front(inst);
|
||||
}
|
||||
|
||||
/// This method unlinks 'self' from the containing SILFunction and deletes it.
|
||||
void SILBasicBlock::eraseFromParent() {
|
||||
getParent()->eraseBlock(this);
|
||||
|
||||
Reference in New Issue
Block a user