Skip to content

Commit db007c8

Browse files
committed
Remove #ifdefs.
1 parent d4ebd0d commit db007c8

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

lld/MachO/Driver.cpp

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,13 @@ static void saveThinArchiveToRepro(ArchiveFile const *file) {
290290
}
291291

292292
struct DeferredFile {
293-
#if LLVM_ENABLE_THREADS
294293
StringRef path;
295294
bool isLazy;
296295
MemoryBufferRef buffer;
297-
#endif
298296
};
299297
using DeferredFiles = std::vector<DeferredFile>;
300298

301-
#if LLVM_ENABLE_THREADS
302-
class SerialBackgroundQueue {
299+
class SerialBackgroundWorkQueue {
303300
std::deque<std::function<void()>> queue;
304301
std::thread *running;
305302
std::mutex mutex;
@@ -339,7 +336,7 @@ class SerialBackgroundQueue {
339336
}
340337
};
341338

342-
static SerialBackgroundQueue pageInQueue;
339+
static SerialBackgroundWorkQueue pageInQueue;
343340

344341
// Most input files have been mapped but not yet paged in.
345342
// This code forces the page-ins on multiple threads so
@@ -376,7 +373,7 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
376373
#endif
377374
};
378375

379-
{ // Create scope for waiting for the taskGroup
376+
if (llvm_is_multithreaded()) { // Create scope for waiting for the taskGroup
380377
std::atomic_size_t index = 0;
381378
llvm::parallel::TaskGroup taskGroup;
382379
for (int w = 0; w < config->readWorkers; w++)
@@ -403,7 +400,6 @@ static void multiThreadedPageIn(const DeferredFiles &deferred) {
403400
multiThreadedPageInBackground(files);
404401
});
405402
}
406-
#endif
407403

408404
static InputFile *processFile(std::optional<MemoryBufferRef> buffer,
409405
DeferredFiles *archiveContents, StringRef path,
@@ -503,10 +499,8 @@ static InputFile *processFile(std::optional<MemoryBufferRef> buffer,
503499
continue;
504500
}
505501

506-
#if LLVM_ENABLE_THREADS
507-
if (archiveContents)
502+
if (config->readWorkers && archiveContents)
508503
archiveContents->push_back({path, isLazy, *mb});
509-
#endif
510504
if (!hasObjCSection(*mb))
511505
continue;
512506
if (Error e = file->fetch(c, "-ObjC"))
@@ -582,11 +576,9 @@ static void deferFile(StringRef path, bool isLazy, DeferredFiles &deferred) {
582576
std::optional<MemoryBufferRef> buffer = readFile(path);
583577
if (!buffer)
584578
return;
585-
#if LLVM_ENABLE_THREADS
586579
if (config->readWorkers)
587580
deferred.push_back({path, isLazy, *buffer});
588581
else
589-
#endif
590582
processFile(buffer, nullptr, path, LoadType::CommandLine, isLazy);
591583
}
592584

@@ -1448,7 +1440,6 @@ static void createFiles(const InputArgList &args) {
14481440
}
14491441
}
14501442

1451-
#if LLVM_ENABLE_THREADS
14521443
if (config->readWorkers) {
14531444
multiThreadedPageIn(deferredFiles);
14541445

@@ -1468,7 +1459,6 @@ static void createFiles(const InputArgList &args) {
14681459

14691460
pageInQueue.stopAllWork = true;
14701461
}
1471-
#endif
14721462
}
14731463

14741464
static void gatherInputSections() {
@@ -1856,17 +1846,16 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
18561846
}
18571847

18581848
if (auto *arg = args.getLastArg(OPT_read_workers)) {
1859-
#if LLVM_ENABLE_THREADS
1860-
StringRef v(arg->getValue());
1861-
unsigned workers = 0;
1862-
if (!llvm::to_integer(v, workers, 0))
1863-
error(arg->getSpelling() +
1864-
": expected a non-negative integer, but got '" + arg->getValue() +
1865-
"'");
1866-
config->readWorkers = workers;
1867-
#else
1868-
error(arg->getSpelling() + ": option unavailable");
1869-
#endif
1849+
if (llvm_is_multithreaded()) {
1850+
StringRef v(arg->getValue());
1851+
unsigned workers = 0;
1852+
if (!llvm::to_integer(v, workers, 0))
1853+
error(arg->getSpelling() +
1854+
": expected a non-negative integer, but got '" + arg->getValue() +
1855+
"'");
1856+
config->readWorkers = workers;
1857+
} else
1858+
error(arg->getSpelling() + ": option unavailable");
18701859
}
18711860
if (auto *arg = args.getLastArg(OPT_threads_eq)) {
18721861
StringRef v(arg->getValue());

0 commit comments

Comments
 (0)