Skip to content

Commit c15f76f

Browse files
committed
SILCloner: correctly map function argument types in cloneFunction
and remove the now unused `SILBasicBlock::cloneArgumentList`
1 parent 231042b commit c15f76f

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ public SwiftObjectHeader {
368368
const SILArgument *getArgument(unsigned i) const { return ArgumentList[i]; }
369369
SILArgument *getArgument(unsigned i) { return ArgumentList[i]; }
370370

371-
void cloneArgumentList(SILBasicBlock *Other);
372-
373371
void moveArgumentList(SILBasicBlock *from);
374372

375373
/// Erase a specific argument from the arg list.

include/swift/SIL/SILCloner.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,12 @@ void SILCloner<ImplClass>::cloneFunction(SILFunction *origF) {
840840
SILFunction *newF = &Builder.getFunction();
841841

842842
auto *newEntryBB = newF->createBasicBlock();
843-
newEntryBB->cloneArgumentList(origF->getEntryBlock());
843+
844+
for (auto *funcArg : origF->begin()->getSILFunctionArguments()) {
845+
auto *newArg = newEntryBB->insertFunctionArgument(newEntryBB->getNumArguments(),
846+
asImpl().remapType(funcArg->getType()), funcArg->getOwnershipKind(), funcArg->getDecl());
847+
newArg->copyFlags(funcArg);
848+
}
844849

845850
// Copy the new entry block arguments into a separate vector purely to
846851
// resolve the type mismatch between SILArgument* and SILValue.

lib/SIL/IR/SILBasicBlock.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,6 @@ void SILBasicBlock::removeDeadBlock() {
151151
eraseFromParent();
152152
}
153153

154-
void SILBasicBlock::cloneArgumentList(SILBasicBlock *Other) {
155-
assert(Other->isEntry() == isEntry() &&
156-
"Expected to both blocks to be entries or not");
157-
if (isEntry()) {
158-
assert(args_empty() && "Expected to have no arguments");
159-
for (auto *FuncArg : Other->getSILFunctionArguments()) {
160-
auto *NewArg =
161-
createFunctionArgument(FuncArg->getType(), FuncArg->getDecl());
162-
NewArg->copyFlags(FuncArg);
163-
}
164-
return;
165-
}
166-
167-
for (auto *PHIArg : Other->getSILPhiArguments()) {
168-
createPhiArgument(PHIArg->getType(), PHIArg->getOwnershipKind(),
169-
PHIArg->getDecl());
170-
}
171-
}
172-
173154
void SILBasicBlock::moveArgumentList(SILBasicBlock *from) {
174155
ArgumentList = std::move(from->ArgumentList);
175156
for (SILArgument *arg : getArguments()) {

0 commit comments

Comments
 (0)