diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-04-15 00:50:54 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-04-15 00:50:54 +0000 |
| commit | 81ab90f7ed3c7420fca87c7339c823f136dcc4e5 (patch) | |
| tree | fa6e1216d6a3f5f0efbbe8db3cb3ffa8f88589ad /clang/lib/CodeGen/CodeGenPGO.cpp | |
| parent | ddfadb46545686450598df07db5139fddeabba89 (diff) | |
| download | bcm5719-llvm-81ab90f7ed3c7420fca87c7339c823f136dcc4e5.tar.gz bcm5719-llvm-81ab90f7ed3c7420fca87c7339c823f136dcc4e5.zip | |
CodeGen: Handle CapturedStmt in instrumentation based profiling
CapturedStmt was being ignored by instrumentation based profiling, and
its counters attributed to the containing function. Instead, we need
to treat this as a top level entity, like we do with blocks.
llvm-svn: 206231
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 4dbd01a6619..80c7e87de36 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -335,6 +335,7 @@ namespace { // traverse them in the parent context. bool TraverseBlockExpr(BlockExpr *BE) { return true; } bool TraverseLambdaBody(LambdaExpr *LE) { return true; } + bool TraverseCapturedStmt(CapturedStmt *CS) { return true; } bool VisitDecl(const Decl *D) { switch (D->getKind()) { @@ -347,6 +348,7 @@ namespace { case Decl::CXXConversion: case Decl::ObjCMethod: case Decl::Block: + case Decl::Captured: CounterMap[D->getBody()] = NextCounter++; break; } @@ -437,6 +439,14 @@ namespace { // parent context. void VisitLambdaExpr(const LambdaExpr *LE) {} + void VisitCapturedDecl(const CapturedDecl *D) { + // Counter tracks entry to the capture body. + RegionCounter Cnt(PGO, D->getBody()); + Cnt.beginRegion(); + CountMap[D->getBody()] = PGO.getCurrentRegionCount(); + Visit(D->getBody()); + } + void VisitObjCMethodDecl(const ObjCMethodDecl *D) { // Counter tracks entry to the method body. RegionCounter Cnt(PGO, D->getBody()); @@ -838,6 +848,8 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { Walker.TraverseDecl(const_cast<ObjCMethodDecl *>(MD)); else if (const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D)) Walker.TraverseDecl(const_cast<BlockDecl *>(BD)); + else if (const CapturedDecl *CD = dyn_cast_or_null<CapturedDecl>(D)) + Walker.TraverseDecl(const_cast<CapturedDecl *>(CD)); NumRegionCounters = Walker.NextCounter; // FIXME: The number of counters isn't sufficient for the hash FunctionHash = NumRegionCounters; @@ -852,6 +864,8 @@ void CodeGenPGO::computeRegionCounts(const Decl *D) { Walker.VisitObjCMethodDecl(MD); else if (const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D)) Walker.VisitBlockDecl(BD); + else if (const CapturedDecl *CD = dyn_cast_or_null<CapturedDecl>(D)) + Walker.VisitCapturedDecl(const_cast<CapturedDecl *>(CD)); } void CodeGenPGO::applyFunctionAttributes(PGOProfileData *PGOData, |

