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