clang plugin: print stats per children as the main process doesn't collect those
MODIFY
ir/memory.cpp
ir/memory.cpp
@@ -607,16 +607,20 @@ void Memory::AliasSet::printStats(ostream &os) {
os << fixed;
os << "\n\nAlias sets statistics\n=====================\n"
- "Only local: " << (only_local / total)
- << "%\nOnly non-local: " << (only_nonlocal / total)
- << "%\n\nBuckets:\n";
+ "Only local: " << only_local
+ << " (" << (only_local / total)
+ << "%)\nOnly non-local: " << only_nonlocal
+ << " (" << (only_nonlocal / total)
+ << "%)\n\nBuckets:\n";
for (unsigned i = 0; i < alias_buckets_vals.size(); ++i) {
os << "\u2264 " << alias_buckets_vals[i] << ": "
- << (alias_buckets_hits[i] / total) << "%\n";
+ << alias_buckets_hits[i]
+ << " (" << (alias_buckets_hits[i] / total) << "%)\n";
}
os << "> " << alias_buckets_vals.back() << ": "
- << (alias_buckets_hits.back() / total) << "%\n";
+ << alias_buckets_hits.back()
+ << " (" << (alias_buckets_hits.back() / total) << "%)\n";
}
void Memory::AliasSet::print(ostream &os) const {

ADD
tests/clang-tv/parallel-alias-stats.c
+// TEST-ARGS: -O3 -mllvm -tv-alias-stats -mllvm -tv-parallel=unrestricted -mllvm --max-subprocesses=2
+
+int f(int *x, int *y) {
+ return *x + *y;
+}
+
+// CHECK: Alias sets statistics

MODIFY
tv/tv.cpp
tv/tv.cpp
@@ -97,6 +97,14 @@ static string toString(const Function &fn) {
return ss.str();
}
+static void showStats() {
+ if (opt_smt_stats)
+ smt::solver_print_stats(*out);
+ if (opt_alias_stats)
+ IR::Memory::printAliasStats(*out);
+}
+
+
struct TVLegacyPass final : public llvm::ModulePass {
static char ID;
bool skip_verify = false;
@@ -260,6 +268,7 @@ struct TVLegacyPass final : public llvm::ModulePass {
done:
if (parallelMgr) {
+ showStats();
signal(SIGALRM, SIG_IGN);
llvm_util_init.reset();
smt_init.reset();
@@ -322,12 +331,10 @@ struct TVLegacyPass final : public llvm::ModulePass {
set_outs(*out);
}
- if (!showed_stats) {
+ // If it is run in parallel, stats are shown by children
+ if (!showed_stats && !parallelMgr) {
showed_stats = true;
- if (opt_smt_stats)
- smt::solver_print_stats(*out);
- if (opt_alias_stats)
- IR::Memory::printAliasStats(*out);
+ showStats();
if (has_failure && !report_filename.empty())
cerr << "Report written to " << report_filename << endl;
}

clang plugin: print stats per children as the main process doesn't collect those (#723)