forked from OSchip/llvm-project
PrintStatistics() and PrintStatisticsJSON() should take StatLock
These two functions iterate over the list of statistics but don't take the lock that protects the iterators from being invalidated by StatisticInfo::addStatistic(). So far, this hasn't been an issue since (in-tree at least) these functions are called by the StatisticInfo destructor so addStatistic() shouldn't be called anymore. However, we do expose them in the public API. Note that this only protects against iterator invalidation and does not protect against ordering issues caused by statistic updates that race with PrintStatistics()/PrintStatisticsJSON(). Thanks to Roman Tereshin for spotting it llvm-svn: 326834
This commit is contained in:
parent
7dc5137581
commit
0f4b015268
|
@ -166,6 +166,7 @@ void llvm::PrintStatistics(raw_ostream &OS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void llvm::PrintStatisticsJSON(raw_ostream &OS) {
|
void llvm::PrintStatisticsJSON(raw_ostream &OS) {
|
||||||
|
sys::SmartScopedLock<true> Reader(*StatLock);
|
||||||
StatisticInfo &Stats = *StatInfo;
|
StatisticInfo &Stats = *StatInfo;
|
||||||
|
|
||||||
Stats.sort();
|
Stats.sort();
|
||||||
|
@ -192,6 +193,7 @@ void llvm::PrintStatisticsJSON(raw_ostream &OS) {
|
||||||
|
|
||||||
void llvm::PrintStatistics() {
|
void llvm::PrintStatistics() {
|
||||||
#if LLVM_ENABLE_STATS
|
#if LLVM_ENABLE_STATS
|
||||||
|
sys::SmartScopedLock<true> Reader(*StatLock);
|
||||||
StatisticInfo &Stats = *StatInfo;
|
StatisticInfo &Stats = *StatInfo;
|
||||||
|
|
||||||
// Statistics not enabled?
|
// Statistics not enabled?
|
||||||
|
|
Loading…
Reference in New Issue