@@ -303,7 +303,7 @@ class SerialBackgroundWorkQueue {
303303 std::mutex mutex;
304304
305305public:
306- bool stopAllWork = false ;
306+ std::atomic_bool stopAllWork = false ;
307307 void queueWork (std::function<void ()> work) {
308308 mutex.lock ();
309309 if (running && queue.empty ()) {
@@ -343,21 +343,24 @@ static SerialBackgroundWorkQueue pageInQueue;
343343// This code forces the page-ins on multiple threads so
344344// the process is not stalled waiting on disk buffer i/o.
345345void multiThreadedPageInBackground (DeferredFiles &deferred) {
346- using namespace std ::chrono;
347346 static const size_t pageSize = Process::getPageSizeEstimate ();
348347 static const size_t largeArchive = 10 * 1024 * 1024 ;
348+ #ifndef NDEBUG
349+ using namespace std ::chrono;
349350 static std::atomic_uint64_t totalBytes = 0 ;
350351 std::atomic_int numDeferedFilesAdvised = 0 ;
351352 auto t0 = high_resolution_clock::now ();
353+ #endif
352354
353355 auto preloadDeferredFile = [&](const DeferredFile &deferredFile) {
354356 const StringRef &buff = deferredFile.buffer .getBuffer ();
355357 if (buff.size () > largeArchive)
356358 return ;
357359
360+ #ifndef NDEBUG
358361 totalBytes += buff.size ();
359362 numDeferedFilesAdvised += 1 ;
360-
363+ # endif
361364#if _WIN32
362365 // Reference all file's mmap'd pages to load them into memory.
363366 for (const char *page = buff.data (), *end = page + buff.size ();
@@ -367,12 +370,14 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
367370 }
368371#else
369372#define DEBUG_TYPE " lld-madvise"
370- auto aligned = llvm::alignAddr (buff.data (), Align (pageSize));
373+ auto aligned =
374+ llvm::alignDown (reinterpret_cast <uintptr_t >(buff.data ()), pageSize);
371375 if (madvise ((void *)aligned, buff.size (), MADV_WILLNEED) < 0 )
372376 LLVM_DEBUG (llvm::dbgs () << " madvise error: " << strerror (errno) << " \n " );
373377#undef DEBUG_TYPE
374378#endif
375379 };
380+
376381 { // Create scope for waiting for the taskGroup
377382 std::atomic_size_t index = 0 ;
378383 llvm::parallel::TaskGroup taskGroup;
@@ -387,11 +392,13 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
387392 });
388393 }
389394
395+ #ifndef NDEBUG
390396 auto dt = high_resolution_clock::now () - t0;
391397 if (Process::GetEnv (" LLD_MULTI_THREAD_PAGE" ))
392398 llvm::dbgs () << " multiThreadedPageIn " << totalBytes << " /"
393399 << numDeferedFilesAdvised << " /" << deferred.size () << " /"
394400 << duration_cast<milliseconds>(dt).count () / 1000 . << " \n " ;
401+ #endif
395402}
396403
397404static void multiThreadedPageIn (const DeferredFiles &deferred) {
0 commit comments