Issue |
138173
|
Summary |
[clang] Enabling `-ftime-report` pollutes the output of `-stats-file`
|
Labels |
clang
|
Assignees |
alanzhao1
|
Reporter |
alanzhao1
|
This has been an issue for a long time (at least Clang 19 since I checked)
If we run Clang with `-Xclang=-stats-file`, we get the following (expected) output:
```sh
$ bin/clang -O0 ~/hello_world.cpp -S -o /dev/null -Xclang=-stats-file=/tmp/stats.txt
$ cat /tmp/stats.txt
{
"asm-printer.EmittedInsts": 38,
"dagcombine.NodesCombined": 1,
"dwarf-eh-prepare.NumCleanupLandingPadsRemaining": 1,
"dwarf-eh-prepare.NumUnwind": 1,
"file-search.NumIncluded": 564,
"file-search.NumMultiIncludeFileOptzn": 288,
"isel.NumDAGBlocks": 5,
"isel.NumDAGIselRetries": 55,
"isel.NumEntryBlocks": 1,
"isel.NumFastIselBlocks": 2,
"isel.NumFastIselFailures": 11,
"isel.NumFastIselSuccess": 13,
"isel.NumFastIselSuccessIndependent": 7,
"isel.NumFastIselSuccessTarget": 6,
"mcexpr.MCExprEvaluate": 24,
"prologepilog.NumBytesStackSpace": 552,
"prologepilog.NumFuncSeen": 1,
"regalloc.NumCoalesced": 17,
"regalloc.NumLoads": 1,
"regalloc.NumStores": 1,
"source-manager.MaxUsedSLocBytes": 3848014,
"stackmaps.NumStackMapFuncSkipped": 1,
"stackmaps.NumStackMapFuncVisited": 1
}
```
However, if we have both `-ftime-report` **and** `-stats-file`, the timers from `-ftime-report` contaminates the output of the stats file:
```sh
$ bin/clang -O0 ~/hello_world.cpp -S -o /dev/null -Xclang=-stats-file=/tmp/stats.txt -ftime-report 2>/dev/null
$ cat /tmp/stats.txt
{
# ...
"time.pass.AlwaysInlinerPass.wall": 7.1525573730468750e-06,
"time.pass.AlwaysInlinerPass.user": 0.0000000000000000e+00,
"time.pass.AlwaysInlinerPass.sys": 7.0000000000000617e-06,
"time.pass.CoroConditionalWrapper.wall": 5.2452087402343750e-06,
"time.pass.CoroConditionalWrapper.user": 0.0000000000000000e+00,
"time.pass.CoroConditionalWrapper.sys": 4.9999999999980616e-06,
# ...etc
}
```
The reason for this is that `llvm::PrintStatisticsJSON(...)` [prints all the timers](https://github.com/llvm/llvm-project/blob/334e05b4b78a5de6efdcb23f208f3453a5b364a0/llvm/lib/Support/Statistic.cpp#L223) when it should only print the statistics counter.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs