summaryrefslogtreecommitdiff
path: root/lld/ELF/ICF.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/ICF.cpp')
-rw-r--r--lld/ELF/ICF.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 8992b6564a8a..ecf0a282420d 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -80,10 +80,11 @@
#include "Symbols.h"
#include "SyntheticSections.h"
#include "Writer.h"
-#include "lld/Common/Threads.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Object/ELF.h"
+#include "llvm/Support/Parallel.h"
+#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/xxhash.h"
#include <algorithm>
#include <atomic>
@@ -91,9 +92,9 @@
using namespace llvm;
using namespace llvm::ELF;
using namespace llvm::object;
+using namespace lld;
+using namespace lld::elf;
-namespace lld {
-namespace elf {
namespace {
template <class ELFT> class ICF {
public:
@@ -399,7 +400,7 @@ template <class ELFT>
void ICF<ELFT>::forEachClass(llvm::function_ref<void(size_t, size_t)> fn) {
// If threading is disabled or the number of sections are
// too small to use threading, call Fn sequentially.
- if (!threadsEnabled || sections.size() < 1024) {
+ if (parallel::strategy.ThreadsRequested == 1 || sections.size() < 1024) {
forEachClassRange(0, sections.size(), fn);
++cnt;
return;
@@ -466,9 +467,8 @@ template <class ELFT> void ICF<ELFT>::run() {
}
// Initially, we use hash values to partition sections.
- parallelForEach(sections, [&](InputSection *s) {
- s->eqClass[0] = xxHash64(s->data());
- });
+ parallelForEach(
+ sections, [&](InputSection *s) { s->eqClass[0] = xxHash64(s->data()); });
for (unsigned cnt = 0; cnt != 2; ++cnt) {
parallelForEach(sections, [&](InputSection *s) {
@@ -525,12 +525,12 @@ template <class ELFT> void ICF<ELFT>::run() {
}
// ICF entry point function.
-template <class ELFT> void doIcf() { ICF<ELFT>().run(); }
-
-template void doIcf<ELF32LE>();
-template void doIcf<ELF32BE>();
-template void doIcf<ELF64LE>();
-template void doIcf<ELF64BE>();
+template <class ELFT> void elf::doIcf() {
+ llvm::TimeTraceScope timeScope("ICF");
+ ICF<ELFT>().run();
+}
-} // namespace elf
-} // namespace lld
+template void elf::doIcf<ELF32LE>();
+template void elf::doIcf<ELF32BE>();
+template void elf::doIcf<ELF64LE>();
+template void elf::doIcf<ELF64BE>();