@@ -90,28 +90,30 @@ class ApplySite {
90
90
91
91
SILModule &getModule () const { return Inst->getModule (); }
92
92
93
- static ApplySite isa (SILNode *node) {
94
- auto *i = dyn_cast<SILInstruction>(node);
95
- if (!i)
96
- return ApplySite ();
97
-
98
- auto kind = ApplySiteKind::fromNodeKind (i->getKind ());
93
+ static ApplySite isa (SILInstruction *inst) {
94
+ auto kind = ApplySiteKind::fromNodeKind (inst->getKind ());
99
95
if (!kind)
100
96
return ApplySite ();
101
97
102
98
switch (kind.getValue ()) {
103
99
case ApplySiteKind::ApplyInst:
104
- return ApplySite (cast<ApplyInst>(node ));
100
+ return ApplySite (cast<ApplyInst>(inst ));
105
101
case ApplySiteKind::BeginApplyInst:
106
- return ApplySite (cast<BeginApplyInst>(node ));
102
+ return ApplySite (cast<BeginApplyInst>(inst ));
107
103
case ApplySiteKind::TryApplyInst:
108
- return ApplySite (cast<TryApplyInst>(node ));
104
+ return ApplySite (cast<TryApplyInst>(inst ));
109
105
case ApplySiteKind::PartialApplyInst:
110
- return ApplySite (cast<PartialApplyInst>(node ));
106
+ return ApplySite (cast<PartialApplyInst>(inst ));
111
107
}
112
108
llvm_unreachable (" covered switch" );
113
109
}
114
110
111
+ static ApplySite isa (SILValue value) {
112
+ if (auto *inst = value->getDefiningInstruction ())
113
+ return ApplySite::isa (inst);
114
+ return ApplySite ();
115
+ }
116
+
115
117
ApplySiteKind getKind () const { return ApplySiteKind (Inst->getKind ()); }
116
118
117
119
explicit operator bool () const { return Inst != nullptr ; }
@@ -181,8 +183,8 @@ class ApplySite {
181
183
// / Calls to (previous_)dynamic_function_ref have a dynamic target function so
182
184
// / we should not optimize them.
183
185
bool canOptimize () const {
184
- return !DynamicFunctionRefInst::classof (getCallee ()) &&
185
- !PreviousDynamicFunctionRefInst::classof (getCallee ());
186
+ return !swift::isa<DynamicFunctionRefInst> (getCallee ()) &&
187
+ !swift::isa<PreviousDynamicFunctionRefInst> (getCallee ());
186
188
}
187
189
188
190
// / Return the type.
@@ -493,24 +495,27 @@ class FullApplySite : public ApplySite {
493
495
FullApplySite (BeginApplyInst *inst) : ApplySite(inst) {}
494
496
FullApplySite (TryApplyInst *inst) : ApplySite(inst) {}
495
497
496
- static FullApplySite isa (SILNode *node) {
497
- auto *i = dyn_cast<SILInstruction>(node);
498
- if (!i)
499
- return FullApplySite ();
500
- auto kind = FullApplySiteKind::fromNodeKind (i->getKind ());
498
+ static FullApplySite isa (SILInstruction *inst) {
499
+ auto kind = FullApplySiteKind::fromNodeKind (inst->getKind ());
501
500
if (!kind)
502
501
return FullApplySite ();
503
502
switch (kind.getValue ()) {
504
503
case FullApplySiteKind::ApplyInst:
505
- return FullApplySite (cast<ApplyInst>(node ));
504
+ return FullApplySite (cast<ApplyInst>(inst ));
506
505
case FullApplySiteKind::BeginApplyInst:
507
- return FullApplySite (cast<BeginApplyInst>(node ));
506
+ return FullApplySite (cast<BeginApplyInst>(inst ));
508
507
case FullApplySiteKind::TryApplyInst:
509
- return FullApplySite (cast<TryApplyInst>(node ));
508
+ return FullApplySite (cast<TryApplyInst>(inst ));
510
509
}
511
510
llvm_unreachable (" covered switch" );
512
511
}
513
512
513
+ static FullApplySite isa (SILValue value) {
514
+ if (auto *inst = value->getDefiningInstruction ())
515
+ return FullApplySite::isa (inst);
516
+ return FullApplySite ();
517
+ }
518
+
514
519
FullApplySiteKind getKind () const {
515
520
return FullApplySiteKind (getInstruction ()->getKind ());
516
521
}
0 commit comments