r253958 - Reduce the stack usage per recursive step when RecursiveASTVisitor cannot perform data recursion.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 25 09:02:41 PST 2015


Guessing this or one of the related patches introduced this build breakage?
I haven't looked at it too carefully yet...

http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/26570/steps/compile/logs/stdio

On Mon, Nov 23, 2015 at 11:13 PM, Richard Smith via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Nov 24 01:13:06 2015
> New Revision: 253958
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253958&view=rev
> Log:
> Reduce the stack usage per recursive step when RecursiveASTVisitor cannot
> perform data recursion.
>
> Modified:
>     cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=253958&r1=253957&r2=253958&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Nov 24 01:13:06
> 2015
> @@ -471,28 +471,10 @@ private:
>    /// \brief Process clauses with list of variables.
>    template <typename T> bool VisitOMPClauseList(T *Node);
>
> -  bool dataTraverse(Stmt *S);
>    bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
>  };
>
>  template <typename Derived>
> -bool RecursiveASTVisitor<Derived>::dataTraverse(Stmt *S) {
> -  SmallVector<Stmt*, 16> Queue;
> -  Queue.push_back(S);
> -
> -  while (!Queue.empty()) {
> -    Stmt *CurrS = Queue.pop_back_val();
> -
> -    size_t N = Queue.size();
> -    TRY_TO(dataTraverseNode(CurrS, &Queue));
> -    // Process new children in the order they were added.
> -    std::reverse(Queue.begin() + N, Queue.end());
> -  }
> -
> -  return true;
> -}
> -
> -template <typename Derived>
>  bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
>                                                      DataRecursionQueue
> *Queue) {
>  #define DISPATCH_STMT(NAME, CLASS, VAR)
>       \
> @@ -561,10 +543,23 @@ bool RecursiveASTVisitor<Derived>::Trave
>                                &RecursiveASTVisitor::TraverseStmt>::value)
>      return dataTraverseNode(S, nullptr);
>
> -  if (!Queue)
> -    return dataTraverse(S);
> +  if (Queue) {
> +    Queue->push_back(S);
> +    return true;
> +  }
> +
> +  SmallVector<Stmt *, 8> LocalQueue;
> +  LocalQueue.push_back(S);
> +
> +  while (!LocalQueue.empty()) {
> +    Stmt *CurrS = LocalQueue.pop_back_val();
> +
> +    size_t N = LocalQueue.size();
> +    TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
> +    // Process new children in the order they were added.
> +    std::reverse(LocalQueue.begin() + N, LocalQueue.end());
> +  }
>
> -  Queue->push_back(S);
>    return true;
>  }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151125/ace62269/attachment-0001.html>


More information about the cfe-commits mailing list