Skip to content

Commit b544355

Browse files
authored
Merge pull request #28525 from gottesmm/pr-026a0d4e88ada556787a0f4b3c2c9844ec67e6e1
2 parents bf6527b + df47eb2 commit b544355

17 files changed

+35
-50
lines changed

include/swift/SIL/SILArgumentArrayRef.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
namespace swift {
2727

2828
class SILArgument;
29-
class SILPhiArgument;
30-
class SILFunctionArgument;
3129

32-
using PhiArgumentArrayRef =
33-
TransformRange<ArrayRef<SILArgument *>, SILPhiArgument *(*)(SILArgument *)>;
34-
35-
using FunctionArgumentArrayRef =
36-
TransformRange<ArrayRef<SILArgument *>,
37-
SILFunctionArgument *(*)(SILArgument *)>;
30+
#define ARGUMENT(NAME, PARENT) \
31+
class NAME; \
32+
using NAME##ArrayRef = \
33+
TransformRange<ArrayRef<SILArgument *>, NAME *(*)(SILArgument *)>;
34+
#include "swift/SIL/SILNodes.def"
3835

3936
} // namespace swift
4037

include/swift/SIL/SILBasicBlock.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace swift {
2626

2727
class SILFunction;
2828
class SILArgument;
29-
class SILPhiArgument;
30-
class SILFunctionArgument;
3129
class SILPrintContext;
3230

3331
class SILBasicBlock :
@@ -193,14 +191,10 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
193191

194192
ArrayRef<SILArgument *> getArguments() const { return ArgumentList; }
195193

196-
/// Returns a transform array ref that performs llvm::cast<SILPhiArgument> on
194+
/// Returns a transform array ref that performs llvm::cast<NAME>
197195
/// each argument and then returns the downcasted value.
198-
PhiArgumentArrayRef getPhiArguments() const;
199-
200-
/// Returns a transform array ref that performs
201-
/// llvm::cast<SILFunctionArgument> on each argument and then returns the
202-
/// downcasted value.
203-
FunctionArgumentArrayRef getFunctionArguments() const;
196+
#define ARGUMENT(NAME, PARENT) NAME##ArrayRef get##NAME##s() const;
197+
#include "swift/SIL/SILNodes.def"
204198

205199
unsigned getNumArguments() const { return ArgumentList.size(); }
206200
const SILArgument *getArgument(unsigned i) const { return ArgumentList[i]; }

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ void SILCloner<ImplClass>::clonePhiArgs(SILBasicBlock *oldBB) {
646646
auto *mappedBB = BBMap[oldBB];
647647

648648
// Create new arguments for each of the original block's arguments.
649-
for (auto *Arg : oldBB->getPhiArguments()) {
649+
for (auto *Arg : oldBB->getSILPhiArguments()) {
650650
SILValue mappedArg = mappedBB->createPhiArgument(
651651
getOpType(Arg->getType()), Arg->getOwnershipKind());
652652

include/swift/SIL/SILInstruction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6989,8 +6989,8 @@ class TermInst : public NonValueInstruction {
69896989
}
69906990

69916991
using SuccessorBlockArgumentsListTy =
6992-
TransformRange<ConstSuccessorListTy,
6993-
function_ref<PhiArgumentArrayRef(const SILSuccessor &)>>;
6992+
TransformRange<ConstSuccessorListTy, function_ref<SILPhiArgumentArrayRef(
6993+
const SILSuccessor &)>>;
69946994

69956995
/// Return the range of Argument arrays for each successor of this
69966996
/// block.

lib/SIL/OperandOwnership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ OperandOwnershipKindClassifier::visitSwitchEnumInst(SwitchEnumInst *sei) {
455455
// and merge them.
456456
auto mergedKind = ValueOwnershipKind::merge(makeTransformRange(
457457
sei->getSuccessorBlockArguments(),
458-
[&](PhiArgumentArrayRef array) -> ValueOwnershipKind {
458+
[&](SILPhiArgumentArrayRef array) -> ValueOwnershipKind {
459459
// If the array is empty, we have a non-payloaded case. Return any.
460460
if (array.empty())
461461
return ValueOwnershipKind::None;

lib/SIL/SILBasicBlock.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ void SILBasicBlock::cloneArgumentList(SILBasicBlock *Other) {
129129
"Expected to both blocks to be entries or not");
130130
if (isEntry()) {
131131
assert(args_empty() && "Expected to have no arguments");
132-
for (auto *FuncArg : Other->getFunctionArguments()) {
132+
for (auto *FuncArg : Other->getSILFunctionArguments()) {
133133
createFunctionArgument(FuncArg->getType(),
134134
FuncArg->getDecl());
135135
}
136136
return;
137137
}
138138

139-
for (auto *PHIArg : Other->getPhiArguments()) {
139+
for (auto *PHIArg : Other->getSILPhiArguments()) {
140140
createPhiArgument(PHIArg->getType(), PHIArg->getOwnershipKind(),
141141
PHIArg->getDecl());
142142
}
@@ -359,18 +359,12 @@ bool SILBasicBlock::isEntry() const {
359359
}
360360

361361
/// Declared out of line so we can have a declaration of SILArgument.
362-
PhiArgumentArrayRef SILBasicBlock::getPhiArguments() const {
363-
return PhiArgumentArrayRef(getArguments(), [](SILArgument *arg) {
364-
return cast<SILPhiArgument>(arg);
365-
});
366-
}
367-
368-
/// Declared out of line so we can have a declaration of SILArgument.
369-
FunctionArgumentArrayRef SILBasicBlock::getFunctionArguments() const {
370-
return FunctionArgumentArrayRef(getArguments(), [](SILArgument *arg) {
371-
return cast<SILFunctionArgument>(arg);
372-
});
373-
}
362+
#define ARGUMENT(NAME, PARENT) \
363+
NAME##ArrayRef SILBasicBlock::get##NAME##s() const { \
364+
return NAME##ArrayRef(getArguments(), \
365+
[](SILArgument *arg) { return cast<NAME>(arg); }); \
366+
}
367+
#include "swift/SIL/SILNodes.def"
374368

375369
/// Returns true if this block ends in an unreachable or an apply of a
376370
/// no-return apply or builtin.

lib/SIL/SILInstructions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,9 +1223,9 @@ bool TermInst::isProgramTerminating() const {
12231223

12241224
TermInst::SuccessorBlockArgumentsListTy
12251225
TermInst::getSuccessorBlockArguments() const {
1226-
function_ref<PhiArgumentArrayRef(const SILSuccessor &)> op;
1227-
op = [](const SILSuccessor &succ) -> PhiArgumentArrayRef {
1228-
return succ.getBB()->getPhiArguments();
1226+
function_ref<SILPhiArgumentArrayRef(const SILSuccessor &)> op;
1227+
op = [](const SILSuccessor &succ) -> SILPhiArgumentArrayRef {
1228+
return succ.getBB()->getSILPhiArguments();
12291229
};
12301230
return SuccessorBlockArgumentsListTy(getSuccessors(), op);
12311231
}

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ bool SILValueOwnershipChecker::gatherUsers(
349349
//
350350
// TODO: We could ignore this error and emit a more specific error on the
351351
// actual terminator.
352-
for (auto *succArg : succBlock->getPhiArguments()) {
352+
for (auto *succArg : succBlock->getSILPhiArguments()) {
353353
// *NOTE* We do not emit an error here since we want to allow for more
354354
// specific errors to be found during use_verification.
355355
//

lib/SILOptimizer/Analysis/ARCAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ void ConsumedArgToEpilogueReleaseMatcher::collectMatchingDestroyAddresses(
843843
SILFunction::iterator anotherEpilogueBB =
844844
(Kind == ExitKind::Return) ? F->findThrowBB() : F->findReturnBB();
845845

846-
for (auto *arg : F->begin()->getFunctionArguments()) {
846+
for (auto *arg : F->begin()->getSILFunctionArguments()) {
847847
if (arg->isIndirectResult())
848848
continue;
849849
if (arg->getArgumentConvention() != SILArgumentConvention::Indirect_In)

lib/SILOptimizer/FunctionSignatureTransforms/ArgumentExplosionTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ bool FunctionSignatureTransform::ArgumentExplosionAnalyzeParameters() {
320320
SILFunction *F = TransformDescriptor.OriginalFunction;
321321
// Did we decide we should optimize any parameter?
322322
bool SignatureOptimize = false;
323-
auto Args = F->begin()->getFunctionArguments();
323+
auto Args = F->begin()->getSILFunctionArguments();
324324
ConsumedArgToEpilogueReleaseMatcher ArgToReturnReleaseMap(
325325
RCIA->get(F), F, {SILArgumentConvention::Direct_Owned});
326326

lib/SILOptimizer/FunctionSignatureTransforms/DeadArgumentTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool FunctionSignatureTransform::DeadArgumentAnalyzeParameters() {
2929
// Did we decide we should optimize any parameter?
3030
SILFunction *F = TransformDescriptor.OriginalFunction;
3131
bool SignatureOptimize = false;
32-
auto Args = F->begin()->getFunctionArguments();
32+
auto Args = F->begin()->getSILFunctionArguments();
3333
auto OrigShouldModifySelfArgument =
3434
TransformDescriptor.shouldModifySelfArgument;
3535
// Analyze the argument information.

lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ bool ExistentialSpecializer::canSpecializeExistentialArgsInFunction(
130130
llvm::SmallDenseMap<int, ExistentialTransformArgumentDescriptor>
131131
&ExistentialArgDescriptor) {
132132
auto *F = Apply.getReferencedFunctionOrNull();
133-
auto CalleeArgs = F->begin()->getFunctionArguments();
133+
auto CalleeArgs = F->begin()->getSILFunctionArguments();
134134
bool returnFlag = false;
135135

136136
/// Analyze the argument for protocol conformance. Iterator over the callee's
@@ -314,7 +314,7 @@ void ExistentialSpecializer::specializeExistentialArgsInAppliesWithinFunction(
314314
/// Save the arguments in a descriptor.
315315
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> Allocator;
316316
llvm::SmallVector<ArgumentDescriptor, 4> ArgumentDescList;
317-
auto Args = Callee->begin()->getFunctionArguments();
317+
auto Args = Callee->begin()->getSILFunctionArguments();
318318
for (unsigned i : indices(Args)) {
319319
ArgumentDescList.emplace_back(Args[i], Allocator);
320320
}

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ void FunctionSignatureTransform::createFunctionSignatureOptimizedFunction() {
538538
ArgumentExplosionFinalizeOptimizedFunction();
539539

540540
// Update the ownership kinds of function entry BB arguments.
541-
for (auto Arg : NewF->begin()->getFunctionArguments()) {
541+
for (auto Arg : NewF->begin()->getSILFunctionArguments()) {
542542
SILType MappedTy = Arg->getType();
543543
auto Ownershipkind =
544544
ValueOwnershipKind(*NewF, MappedTy, Arg->getArgumentConvention());
@@ -826,7 +826,7 @@ class FunctionSignatureOpts : public SILFunctionTransform {
826826
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> Allocator;
827827
llvm::SmallVector<ArgumentDescriptor, 4> ArgumentDescList;
828828
llvm::SmallVector<ResultDescriptor, 4> ResultDescList;
829-
auto Args = F->begin()->getFunctionArguments();
829+
auto Args = F->begin()->getSILFunctionArguments();
830830
for (unsigned i : indices(Args)) {
831831
ArgumentDescList.emplace_back(Args[i], Allocator);
832832
}

lib/SILOptimizer/FunctionSignatureTransforms/OwnedToGuaranteedTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static SILInstruction *findOnlyApply(SILFunction *F) {
5656

5757
bool FunctionSignatureTransform::OwnedToGuaranteedAnalyzeParameters() {
5858
SILFunction *F = TransformDescriptor.OriginalFunction;
59-
auto Args = F->begin()->getFunctionArguments();
59+
auto Args = F->begin()->getSILFunctionArguments();
6060
// A map from consumed SILArguments to the release associated with an
6161
// argument.
6262
//

lib/SILOptimizer/IPO/EagerSpecializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ SILValue EagerDispatch::emitArgumentCast(CanSILFunctionType CalleeSubstFnTy,
619619
/// has a direct result.
620620
SILValue EagerDispatch::
621621
emitArgumentConversion(SmallVectorImpl<SILValue> &CallArgs) {
622-
auto OrigArgs = GenericFunc->begin()->getFunctionArguments();
622+
auto OrigArgs = GenericFunc->begin()->getSILFunctionArguments();
623623
assert(OrigArgs.size() == substConv.getNumSILArguments()
624624
&& "signature mismatch");
625625
// Create a substituted callee type.

lib/SILOptimizer/Transforms/CSE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ static void updateBasicBlockArgTypes(SILBasicBlock *BB,
618618
ArchetypeType *OldOpenedArchetype,
619619
ArchetypeType *NewOpenedArchetype) {
620620
// Check types of all BB arguments.
621-
for (auto *Arg : BB->getPhiArguments()) {
621+
for (auto *Arg : BB->getSILPhiArguments()) {
622622
if (!Arg->getType().hasOpenedExistential())
623623
continue;
624624
// Type of this BB argument uses an opened existential.

lib/SILOptimizer/Utils/SILSSAUpdater.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ SILValue SILSSAUpdater::GetValueInMiddleOfBlock(SILBasicBlock *BB) {
221221
if (!BB->getArguments().empty()) {
222222
llvm::SmallDenseMap<SILBasicBlock *, SILValue, 8> ValueMap(PredVals.begin(),
223223
PredVals.end());
224-
for (auto *Arg : BB->getPhiArguments())
224+
for (auto *Arg : BB->getSILPhiArguments())
225225
if (isEquivalentPHI(Arg, ValueMap))
226226
return Arg;
227227

0 commit comments

Comments
 (0)