@@ -90,30 +90,28 @@ class ApplySite {
9090
9191 SILModule &getModule () const { return Inst->getModule (); }
9292
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 ());
9599 if (!kind)
96100 return ApplySite ();
97101
98102 switch (kind.getValue ()) {
99103 case ApplySiteKind::ApplyInst:
100- return ApplySite (cast<ApplyInst>(inst ));
104+ return ApplySite (cast<ApplyInst>(node ));
101105 case ApplySiteKind::BeginApplyInst:
102- return ApplySite (cast<BeginApplyInst>(inst ));
106+ return ApplySite (cast<BeginApplyInst>(node ));
103107 case ApplySiteKind::TryApplyInst:
104- return ApplySite (cast<TryApplyInst>(inst ));
108+ return ApplySite (cast<TryApplyInst>(node ));
105109 case ApplySiteKind::PartialApplyInst:
106- return ApplySite (cast<PartialApplyInst>(inst ));
110+ return ApplySite (cast<PartialApplyInst>(node ));
107111 }
108112 llvm_unreachable (" covered switch" );
109113 }
110114
111- static ApplySite isa (SILValue value) {
112- if (auto *inst = value->getDefiningInstruction ())
113- return ApplySite::isa (inst);
114- return ApplySite ();
115- }
116-
117115 ApplySiteKind getKind () const { return ApplySiteKind (Inst->getKind ()); }
118116
119117 explicit operator bool () const { return Inst != nullptr ; }
@@ -183,8 +181,8 @@ class ApplySite {
183181 // / Calls to (previous_)dynamic_function_ref have a dynamic target function so
184182 // / we should not optimize them.
185183 bool canOptimize () const {
186- return !swift::isa<DynamicFunctionRefInst> (getCallee ()) &&
187- !swift::isa<PreviousDynamicFunctionRefInst> (getCallee ());
184+ return !DynamicFunctionRefInst::classof (getCallee ()) &&
185+ !PreviousDynamicFunctionRefInst::classof (getCallee ());
188186 }
189187
190188 // / Return the type.
@@ -495,27 +493,24 @@ class FullApplySite : public ApplySite {
495493 FullApplySite (BeginApplyInst *inst) : ApplySite(inst) {}
496494 FullApplySite (TryApplyInst *inst) : ApplySite(inst) {}
497495
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 ());
500501 if (!kind)
501502 return FullApplySite ();
502503 switch (kind.getValue ()) {
503504 case FullApplySiteKind::ApplyInst:
504- return FullApplySite (cast<ApplyInst>(inst ));
505+ return FullApplySite (cast<ApplyInst>(node ));
505506 case FullApplySiteKind::BeginApplyInst:
506- return FullApplySite (cast<BeginApplyInst>(inst ));
507+ return FullApplySite (cast<BeginApplyInst>(node ));
507508 case FullApplySiteKind::TryApplyInst:
508- return FullApplySite (cast<TryApplyInst>(inst ));
509+ return FullApplySite (cast<TryApplyInst>(node ));
509510 }
510511 llvm_unreachable (" covered switch" );
511512 }
512513
513- static FullApplySite isa (SILValue value) {
514- if (auto *inst = value->getDefiningInstruction ())
515- return FullApplySite::isa (inst);
516- return FullApplySite ();
517- }
518-
519514 FullApplySiteKind getKind () const {
520515 return FullApplySiteKind (getInstruction ()->getKind ());
521516 }
0 commit comments