r206039 - [PGO] Change MapRegionCounters to be a RecursiveASTVisitor.

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Apr 11 10:43:44 PDT 2014


On Apr 11, 2014, at 10:16, Bob Wilson <bob.wilson at apple.com> wrote:

> Author: bwilson
> Date: Fri Apr 11 12:16:13 2014
> New Revision: 206039
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=206039&view=rev
> Log:
> [PGO] Change MapRegionCounters to be a RecursiveASTVisitor.
> 
> This avoids the overhead of specifying all the traversal code when using
> ConstStmtVisitor and makes it a lot easier to maintain this.
> 
> Modified:
>    cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=206039&r1=206038&r2=206039&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 11 12:16:13 2014
> @@ -321,8 +321,8 @@ llvm::Function *CodeGenPGO::emitInitiali
> }
> 
> namespace {
> -  /// A StmtVisitor that fills a map of statements to PGO counters.
> -  struct MapRegionCounters : public ConstStmtVisitor<MapRegionCounters> {
> +  /// A RecursiveASTVisitor that fills a map of statements to PGO counters.
> +  struct MapRegionCounters : public RecursiveASTVisitor<MapRegionCounters> {
>     /// The next counter value to assign.
>     unsigned NextCounter;
>     /// The map of statements to counters.
> @@ -331,135 +331,55 @@ namespace {
>     MapRegionCounters(llvm::DenseMap<const Stmt *, unsigned> &CounterMap)
>         : NextCounter(0), CounterMap(CounterMap) {}
> 
> -    void VisitChildren(const Stmt *S) {
> -      for (Stmt::const_child_range I = S->children(); I; ++I)
> -        if (*I)
> -         this->Visit(*I);
> +    // Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl
> +    // is handled as a separate function.
> +    bool TraverseBlockExpr(BlockExpr *block) { return true; }

Do we need something similar for C++11 lambdas?



More information about the cfe-commits mailing list