[ASan] change interface of GetAccumulatedStats() function to prevent Clang from inserting memcpy() call into runtime.

llvm-svn: 168305
This commit is contained in:
Alexey Samsonov 2012-11-19 10:25:17 +00:00
parent b54ac2193f
commit 06b22c1513
3 changed files with 6 additions and 5 deletions

View File

@ -56,7 +56,8 @@ void AsanStats::Print() {
static AsanLock print_lock(LINKER_INITIALIZED);
static void PrintAccumulatedStats() {
AsanStats stats = asanThreadRegistry().GetAccumulatedStats();
AsanStats stats;
asanThreadRegistry().GetAccumulatedStats(&stats);
// Use lock to keep reports from mixing up.
ScopedLock lock(&print_lock);
stats.Print();

View File

@ -104,10 +104,10 @@ AsanStats &AsanThreadRegistry::GetCurrentThreadStats() {
return (t) ? t->stats() : main_thread_.stats();
}
AsanStats AsanThreadRegistry::GetAccumulatedStats() {
void AsanThreadRegistry::GetAccumulatedStats(AsanStats *stats) {
ScopedLock lock(&mu_);
UpdateAccumulatedStatsUnlocked();
return accumulated_stats_;
internal_memcpy(stats, &accumulated_stats_, sizeof(accumulated_stats_));
}
uptr AsanThreadRegistry::GetCurrentAllocatedBytes() {

View File

@ -47,9 +47,9 @@ class AsanThreadRegistry {
// Returns stats for GetCurrent(), or stats for
// T0 if GetCurrent() returns 0.
AsanStats &GetCurrentThreadStats();
// Flushes all thread-local stats to accumulated stats, and returns
// Flushes all thread-local stats to accumulated stats, and makes
// a copy of accumulated stats.
AsanStats GetAccumulatedStats();
void GetAccumulatedStats(AsanStats *stats);
uptr GetCurrentAllocatedBytes();
uptr GetHeapSize();
uptr GetFreeBytes();