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 | e7d930cc59db208489d79ab38219aa9f847eba26 (patch) | |
tree | 36cd66cdfb9b1eda42297b308f4f067643e27e37 /lib/CodeGen/CodeGenPGO.h | |
parent | ea0117fbc60fd03749405102aff6963231c6c849 (diff) |
InstrProf: Simplify getStmtCount by using an Optional
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234750 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenPGO.h')
-rw-r--r-- | lib/CodeGen/CodeGenPGO.h | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/CodeGen/CodeGenPGO.h b/lib/CodeGen/CodeGenPGO.h index 431c850ef8..c92a057950 100644 --- a/lib/CodeGen/CodeGenPGO.h +++ b/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 |