diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2014-03-06 20:24:27 +0000 |
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2014-03-06 20:24:27 +0000 |
| commit | fae8726799aae7c7b1f6209275b7033167abbd3d (patch) | |
| tree | 3b66146899abdfac0b48af1cf2478796afed2e67 /lib/CodeGen/CodeGenPGO.cpp | |
| parent | 6418873878c4163af4af691db26c257e5d9b35a0 (diff) | |
| download | clang-fae8726799aae7c7b1f6209275b7033167abbd3d.tar.gz clang-fae8726799aae7c7b1f6209275b7033167abbd3d.tar.bz2 clang-fae8726799aae7c7b1f6209275b7033167abbd3d.tar.xz | |
PGO: Add support for Objective-C blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenPGO.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenPGO.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenPGO.cpp b/lib/CodeGen/CodeGenPGO.cpp index 349160ad35..cdd411cfa3 100644 --- a/lib/CodeGen/CodeGenPGO.cpp +++ b/lib/CodeGen/CodeGenPGO.cpp @@ -315,6 +315,10 @@ namespace { (*CounterMap)[S->getBody()] = NextCounter++; Visit(S->getBody()); } + void VisitBlockDecl(const BlockDecl *S) { + (*CounterMap)[S->getBody()] = NextCounter++; + Visit(S->getBody()); + } /// Assign a counter to track the block following a label. void VisitLabelStmt(const LabelStmt *S) { (*CounterMap)[S] = NextCounter++; @@ -481,6 +485,13 @@ namespace { Visit(S->getBody()); } + void VisitBlockDecl(const BlockDecl *S) { + RegionCounter Cnt(PGO, S->getBody()); + Cnt.beginRegion(); + (*CountMap)[S->getBody()] = PGO.getCurrentRegionCount(); + Visit(S->getBody()); + } + void VisitReturnStmt(const ReturnStmt *S) { RecordStmtCount(S); if (S->getRetValue()) @@ -802,6 +813,8 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { Walker.VisitFunctionDecl(FD); else if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D)) Walker.VisitObjCMethodDecl(MD); + else if (const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D)) + Walker.VisitBlockDecl(BD); NumRegionCounters = Walker.NextCounter; } @@ -812,6 +825,8 @@ void CodeGenPGO::computeRegionCounts(const Decl *D) { Walker.VisitFunctionDecl(FD); else if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D)) Walker.VisitObjCMethodDecl(MD); + else if (const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D)) + Walker.VisitBlockDecl(BD); } void CodeGenPGO::emitCounterVariables() { |
