|
10 | 10 | // |
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 |
|
13 | | -#include "clang/AST/Decl.h" |
| 13 | +#include "swift/Basic/Statistic.h" |
| 14 | +#include "swift/Config.h" |
14 | 15 | #include "clang/Basic/SourceLocation.h" |
15 | 16 | #include "clang/Basic/SourceManager.h" |
16 | | -#include "swift/Basic/Statistic.h" |
17 | | -#include "swift/AST/Decl.h" |
18 | | -#include "swift/AST/Expr.h" |
19 | 17 | #include "llvm/ADT/DenseMap.h" |
20 | 18 | #include "llvm/Config/config.h" |
21 | 19 | #include "llvm/Support/FileSystem.h" |
22 | 20 | #include "llvm/Support/Path.h" |
23 | 21 | #include "llvm/Support/Process.h" |
24 | | -#include "llvm/Support/raw_ostream.h" |
25 | 22 | #include "llvm/Support/SaveAndRestore.h" |
| 23 | +#include "llvm/Support/raw_ostream.h" |
26 | 24 | #include <chrono> |
27 | 25 | #include <limits> |
28 | 26 |
|
@@ -59,6 +57,16 @@ bool environmentVariableRequestedMaximumDeterminism() { |
59 | 57 | return false; |
60 | 58 | } |
61 | 59 |
|
| 60 | +uint64_t getInstructionsExecuted() { |
| 61 | +#if defined(HAVE_PROC_PID_RUSAGE) && defined(RUSAGE_INFO_V4) |
| 62 | + struct rusage_info_v4 ru; |
| 63 | + if (proc_pid_rusage(getpid(), RUSAGE_INFO_V4, (rusage_info_t *)&ru) == 0) { |
| 64 | + return ru.ri_instructions; |
| 65 | + } |
| 66 | +#endif |
| 67 | + return 0; |
| 68 | +} |
| 69 | + |
62 | 70 | static std::string |
63 | 71 | makeFileName(StringRef Prefix, |
64 | 72 | StringRef ProgramName, |
@@ -510,12 +518,9 @@ FrontendStatsTracer::~FrontendStatsTracer() |
510 | 518 | // associated fields in the provided AlwaysOnFrontendCounters. |
511 | 519 | void updateProcessWideFrontendCounters( |
512 | 520 | UnifiedStatsReporter::AlwaysOnFrontendCounters &C) { |
513 | | -#if defined(HAVE_PROC_PID_RUSAGE) && defined(RUSAGE_INFO_V4) |
514 | | - struct rusage_info_v4 ru; |
515 | | - if (0 == proc_pid_rusage(getpid(), RUSAGE_INFO_V4, (rusage_info_t *)&ru)) { |
516 | | - C.NumInstructionsExecuted = ru.ri_instructions; |
| 521 | + if (auto instrExecuted = getInstructionsExecuted()) { |
| 522 | + C.NumInstructionsExecuted = instrExecuted; |
517 | 523 | } |
518 | | -#endif |
519 | 524 |
|
520 | 525 | #if defined(HAVE_MALLOC_ZONE_STATISTICS) && defined(HAVE_MALLOC_MALLOC_H) |
521 | 526 | // On Darwin we have a lifetime max that's maintained by malloc we can |
|
0 commit comments