diff options
| author | Justin Bogner <mail@justinbogner.com> | 2015-04-13 12:23:19 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2015-04-13 12:23:19 +0000 |
| commit | 1c21c28b9e0b8c90dbbb23e23be008a258fd6e6b (patch) | |
| tree | ba3c7015d6306160748bffa80e7111301b945624 /clang/lib/CodeGen/CodeGenPGO.h | |
| parent | cced470374a43dda437e3413673971bd204eff75 (diff) | |
| download | bcm5719-llvm-1c21c28b9e0b8c90dbbb23e23be008a258fd6e6b.tar.gz bcm5719-llvm-1c21c28b9e0b8c90dbbb23e23be008a258fd6e6b.zip | |
InstrProf: Simplify getStmtCount by using an Optional
llvm-svn: 234750
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.h')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.h | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h index 431c850ef81..c92a0579507 100644 --- a/clang/lib/CodeGen/CodeGenPGO.h +++ b/clang/lib/CodeGen/CodeGenPGO.h @@ -69,23 +69,20 @@ public: /// Check if an execution count is known for a given statement. If so, return /// true and put the value in Count; else return false. - bool getStmtCount(const Stmt *S, uint64_t &Count) { + Optional<uint64_t> getStmtCount(const Stmt *S) { if (!StmtCountMap) - return false; - llvm::DenseMap<const Stmt*, uint64_t>::const_iterator - I = StmtCountMap->find(S); + return None; + auto I = StmtCountMap->find(S); if (I == StmtCountMap->end()) - return false; - Count = I->second; - return true; + return None; + return I->second; } /// If the execution count for the current statement is known, record that /// as the current count. void setCurrentStmt(const Stmt *S) { - uint64_t Count; - if (getStmtCount(S, Count)) - setCurrentRegionCount(Count); + if (auto Count = getStmtCount(S)) + setCurrentRegionCount(*Count); } /// Calculate branch weights appropriate for PGO data |

