25
25
#include " llvm/Support/Process.h"
26
26
#include " llvm/Support/raw_ostream.h"
27
27
#include < chrono>
28
+ #include < limits>
28
29
29
30
#ifdef HAVE_SYS_TIME_H
30
31
#include < sys/time.h>
@@ -37,12 +38,15 @@ namespace swift {
37
38
using namespace llvm ;
38
39
using namespace llvm ::sys;
39
40
40
- static size_t
41
+ static int64_t
41
42
getChildrenMaxResidentSetSize () {
42
43
#if defined(HAVE_GETRUSAGE) && !defined(__HAIKU__)
43
44
struct rusage RU;
44
45
::getrusage (RUSAGE_CHILDREN, &RU);
45
- return RU.ru_maxrss ;
46
+ int64_t M = static_cast <int64_t >(RU.ru_maxrss );
47
+ if (M < 0 )
48
+ M = std::numeric_limits<int64_t >::max ();
49
+ return M;
46
50
#else
47
51
return 0 ;
48
52
#endif
@@ -377,8 +381,8 @@ UnifiedStatsReporter::saveAnyFrontendStatsEvents(
377
381
auto &C = getFrontendCounters ();
378
382
#define FRONTEND_STATISTIC (TY, NAME ) \
379
383
do { \
380
- auto total = C.NAME ; \
381
- auto delta = C.NAME - LastTracedFrontendCounters->NAME ; \
384
+ int64_t total = C.NAME ; \
385
+ int64_t delta = C.NAME - LastTracedFrontendCounters->NAME ; \
382
386
static char const *name = #TY " ." #NAME; \
383
387
if (delta != 0 ) { \
384
388
LastTracedFrontendCounters->NAME = C.NAME ; \
@@ -428,8 +432,8 @@ UnifiedStatsReporter::~UnifiedStatsReporter()
428
432
auto &C = getFrontendCounters ();
429
433
// Convenience calculation for crude top-level "absolute speed".
430
434
if (C.NumSourceLines != 0 && ElapsedTime.getProcessTime () != 0.0 )
431
- C.NumSourceLinesPerSecond = (size_t ) (((double )C.NumSourceLines ) /
432
- ElapsedTime.getProcessTime ());
435
+ C.NumSourceLinesPerSecond = (int64_t ) (((double )C.NumSourceLines ) /
436
+ ElapsedTime.getProcessTime ());
433
437
}
434
438
435
439
std::error_code EC;
0 commit comments