Skip to content

[sil] Change TermInst::getSuccessorBlockArguments() to yield SILArguments instead of SILPhiArgument since I am going to be adding SwitchEnumResult (which the API can vend as well). #28993

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
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
2 changes: 1 addition & 1 deletion include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -7000,7 +7000,7 @@ class TermInst : public NonValueInstruction {
}

using SuccessorBlockArgumentListTy =
TransformRange<ConstSuccessorListTy, function_ref<SILPhiArgumentArrayRef(
TransformRange<ConstSuccessorListTy, function_ref<ArrayRef<SILArgument *>(
const SILSuccessor &)>>;

/// Return the range of Argument arrays for each successor of this
Expand Down
5 changes: 2 additions & 3 deletions lib/SIL/OperandOwnership.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,15 @@ OperandOwnershipKindClassifier::visitSwitchEnumInst(SwitchEnumInst *sei) {
// and merge them.
auto mergedKind = ValueOwnershipKind::merge(makeTransformRange(
sei->getSuccessorBlockArgumentLists(),
[&](SILPhiArgumentArrayRef array) -> ValueOwnershipKind {
[&](ArrayRef<SILArgument *> array) -> ValueOwnershipKind {
// If the array is empty, we have a non-payloaded case. Return any.
if (array.empty())
return ValueOwnershipKind::None;

// Otherwise, we should have a single element since a payload is
// a tuple.
assert(std::distance(array.begin(), array.end()) == 1);
SILPhiArgument *arg = array.front();
return arg->getOwnershipKind();
return array.front()->getOwnershipKind();
}));

// If we failed to merge, return an empty map so we will fail to pattern match
Expand Down
6 changes: 3 additions & 3 deletions lib/SIL/SILInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,9 @@ bool TermInst::isProgramTerminating() const {

TermInst::SuccessorBlockArgumentListTy
TermInst::getSuccessorBlockArgumentLists() const {
function_ref<SILPhiArgumentArrayRef(const SILSuccessor &)> op;
op = [](const SILSuccessor &succ) -> SILPhiArgumentArrayRef {
return succ.getBB()->getSILPhiArguments();
function_ref<ArrayRef<SILArgument *>(const SILSuccessor &)> op;
op = [](const SILSuccessor &succ) -> ArrayRef<SILArgument *> {
return succ.getBB()->getArguments();
};
return SuccessorBlockArgumentListTy(getSuccessors(), op);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/SILOptimizer/Mandatory/ClosureLifetimeFixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ cleanupDeadTrivialPhiArgs(SILValue initialValue,
if (ReverseInitialWorklist) {
std::reverse(insertedPhis.begin(), insertedPhis.end());
}
SmallVector<SILPhiArgument *, 8> worklist(insertedPhis.begin(),
insertedPhis.end());
SmallVector<SILArgument *, 8> worklist(insertedPhis.begin(),
insertedPhis.end());
sortUnique(insertedPhis);
SmallVector<SILValue, 8> incomingValues;

Expand Down Expand Up @@ -189,7 +189,7 @@ cleanupDeadTrivialPhiArgs(SILValue initialValue,
auto *termInst = cast<TermInst>(user);
for (auto succBlockArgList : termInst->getSuccessorBlockArgumentLists()) {
llvm::copy_if(succBlockArgList, std::back_inserter(worklist),
[&](SILPhiArgument *succArg) -> bool {
[&](SILArgument *succArg) -> bool {
auto it = lower_bound(insertedPhis, succArg);
return it != insertedPhis.end() && *it == succArg;
});
Expand Down
5 changes: 3 additions & 2 deletions lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,9 @@ static bool
terminatorHasAnyKnownPhis(TermInst *ti,
ArrayRef<SILPhiArgument *> insertedPhiNodesSorted) {
for (auto succArgList : ti->getSuccessorBlockArgumentLists()) {
if (llvm::any_of(succArgList, [&](SILPhiArgument *arg) {
return binary_search(insertedPhiNodesSorted, arg);
if (llvm::any_of(succArgList, [&](SILArgument *arg) {
return binary_search(insertedPhiNodesSorted,
cast<SILPhiArgument>(arg));
})) {
return true;
}
Expand Down