summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-04-11 23:06:35 +0000
committerJustin Bogner <mail@justinbogner.com>2014-04-11 23:06:35 +0000
commit191ec63b718d85b3445bfb29b01a3f4ddee989e2 (patch)
tree25412712fe5b7b729b3c63afb93f1c394c719bb6 /clang/lib/CodeGen/CodeGenPGO.cpp
parentb60e61c15fce38f031576adb7bd2d78b3382a916 (diff)
downloadbcm5719-llvm-191ec63b718d85b3445bfb29b01a3f4ddee989e2.tar.gz
bcm5719-llvm-191ec63b718d85b3445bfb29b01a3f4ddee989e2.zip
CodeGen: Fix handling of C++11 lambdas in profiling
Until now we were generating duplicate counters for lambdas: one set in the function where the lambda was declared and another for the lambda itself. Instead, we should skip over the bodies of lambdas in their containing contexts. llvm-svn: 206081
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 37ba0fb8851..4dbd01a6619 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -331,9 +331,10 @@ namespace {
MapRegionCounters(llvm::DenseMap<const Stmt *, unsigned> &CounterMap)
: NextCounter(0), CounterMap(CounterMap) {}
- // Do not traverse the BlockDecl inside a BlockExpr since each BlockDecl
- // is handled as a separate function.
- bool TraverseBlockExpr(BlockExpr *block) { return true; }
+ // Blocks and lambdas are handled as separate functions, so we need not
+ // traverse them in the parent context.
+ bool TraverseBlockExpr(BlockExpr *BE) { return true; }
+ bool TraverseLambdaBody(LambdaExpr *LE) { return true; }
bool VisitDecl(const Decl *D) {
switch (D->getKind()) {
@@ -431,6 +432,11 @@ namespace {
Visit(D->getBody());
}
+ // Skip lambda expressions. We visit these as FunctionDecls when we're
+ // generating them and aren't interested in the body when generating a
+ // parent context.
+ void VisitLambdaExpr(const LambdaExpr *LE) {}
+
void VisitObjCMethodDecl(const ObjCMethodDecl *D) {
// Counter tracks entry to the method body.
RegionCounter Cnt(PGO, D->getBody());
OpenPOWER on IntegriCloud