@@ -5604,63 +5604,6 @@ bool Compiler::fgHeadMerge(BasicBlock* block, bool early)
56045604 return madeChanges;
56055605}
56065606
5607- // ------------------------------------------------------------------------
5608- // gtTreeContainsCall:
5609- // Check if a tree contains a call node matching the given predicate.
5610- //
5611- // Parameters:
5612- // tree - The tree
5613- // pred - Predicate that the call must match
5614- //
5615- // Returns:
5616- // True if a call node matching the predicate was found, false otherwise.
5617- //
5618- template <typename Predicate>
5619- bool Compiler::gtTreeContainsCall (GenTree* tree, Predicate pred)
5620- {
5621- struct HasCallVisitor : GenTreeVisitor<HasCallVisitor>
5622- {
5623- private:
5624- Predicate& m_pred;
5625-
5626- public:
5627- enum
5628- {
5629- DoPreOrder = true
5630- };
5631-
5632- HasCallVisitor (Compiler* comp, Predicate& pred)
5633- : GenTreeVisitor<HasCallVisitor>(comp)
5634- , m_pred(pred)
5635- {
5636- }
5637-
5638- fgWalkResult PreOrderVisit (GenTree** use, GenTree* user)
5639- {
5640- GenTree* node = *use;
5641- if ((node->gtFlags & GTF_CALL) == 0 )
5642- {
5643- return WALK_SKIP_SUBTREES;
5644- }
5645-
5646- if (node->IsCall () && m_pred (node->AsCall ()))
5647- {
5648- return WALK_ABORT;
5649- }
5650-
5651- return WALK_CONTINUE;
5652- }
5653- };
5654-
5655- if ((tree->gtFlags & GTF_CALL) == 0 )
5656- {
5657- return false ;
5658- }
5659-
5660- HasCallVisitor hasCall (this , pred);
5661- return hasCall.WalkTree (&tree, nullptr ) == WALK_ABORT;
5662- }
5663-
56645607// ------------------------------------------------------------------------
56655608// gtTreeContainsTailCall: Check if a tree contains any tail call or tail call
56665609// candidate.
@@ -5676,9 +5619,11 @@ bool Compiler::gtTreeContainsCall(GenTree* tree, Predicate pred)
56765619//
56775620bool Compiler::gtTreeContainsTailCall (GenTree* tree)
56785621{
5679- return gtTreeContainsCall (tree, [](GenTreeCall* call) {
5680- return call->CanTailCall () || call->IsTailCall ();
5681- });
5622+ auto isTailCall = [](GenTree* tree) {
5623+ return tree->IsCall () && (tree->AsCall ()->CanTailCall () || tree->AsCall ()->IsTailCall ());
5624+ };
5625+
5626+ return gtFindNodeInTree<GTF_CALL>(tree, isTailCall) != nullptr ;
56825627}
56835628
56845629// ------------------------------------------------------------------------
@@ -5697,9 +5642,11 @@ bool Compiler::gtTreeContainsAsyncCall(GenTree* tree)
56975642 return false ;
56985643 }
56995644
5700- return gtTreeContainsCall (tree, [](GenTreeCall* call) {
5701- return call->IsAsync ();
5702- });
5645+ auto isAsyncCall = [](GenTree* tree) {
5646+ return tree->IsCall () && tree->AsCall ()->IsAsync ();
5647+ };
5648+
5649+ return gtFindNodeInTree<GTF_CALL>(tree, isAsyncCall) != nullptr ;
57035650}
57045651
57055652// ------------------------------------------------------------------------
0 commit comments