summaryrefslogtreecommitdiff
path: root/gnu/llvm/tools/lld
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2017-01-14 19:56:09 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2017-01-14 19:56:09 +0000
commite71ad5fbc2d616fafda7b18d6ce16d7b83086bc1 (patch)
tree472308e37d1ce5780d389325fa6d5756462ffb32 /gnu/llvm/tools/lld
parentdd108df16423a7a8bfc250e9cc68d0f273414c03 (diff)
Import LLVM 3.9.1 including clang and lld.
Diffstat (limited to 'gnu/llvm/tools/lld')
-rw-r--r--gnu/llvm/tools/lld/COFF/Librarian.cpp39
-rw-r--r--gnu/llvm/tools/lld/COFF/ModuleDef.cpp12
-rw-r--r--gnu/llvm/tools/lld/include/lld/Core/Parallel.h69
3 files changed, 39 insertions, 81 deletions
diff --git a/gnu/llvm/tools/lld/COFF/Librarian.cpp b/gnu/llvm/tools/lld/COFF/Librarian.cpp
index 4c597fad734..25fb4a87b3e 100644
--- a/gnu/llvm/tools/lld/COFF/Librarian.cpp
+++ b/gnu/llvm/tools/lld/COFF/Librarian.cpp
@@ -54,7 +54,7 @@ static uint16_t getImgRelRelocation() {
}
}
-template <class T> static void append(std::vector<uint8_t> &B, const T &Data) {
+template <class T> void append(std::vector<uint8_t> &B, const T &Data) {
size_t S = B.size();
B.resize(S + sizeof(T));
memcpy(&B[S], &Data, sizeof(T));
@@ -352,16 +352,15 @@ ObjectFactory::createNullImportDescriptor(std::vector<uint8_t> &Buffer) {
NewArchiveMember ObjectFactory::createNullThunk(std::vector<uint8_t> &Buffer) {
static const uint32_t NumberOfSections = 2;
static const uint32_t NumberOfSymbols = 1;
- uint32_t VASize = is32bit() ? 4 : 8;
// COFF Header
coff_file_header Header{
u16(Config->Machine), u16(NumberOfSections), u32(0),
u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section)) +
// .idata$5
- VASize +
+ sizeof(export_address_table_entry) +
// .idata$4
- VASize),
+ sizeof(export_address_table_entry)),
u32(NumberOfSymbols), u16(0),
u16(is32bit() ? IMAGE_FILE_32BIT_MACHINE : 0),
};
@@ -372,40 +371,36 @@ NewArchiveMember ObjectFactory::createNullThunk(std::vector<uint8_t> &Buffer) {
{{'.', 'i', 'd', 'a', 't', 'a', '$', '5'},
u32(0),
u32(0),
- u32(VASize),
+ u32(sizeof(export_address_table_entry)),
u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section)),
u32(0),
u32(0),
u16(0),
u16(0),
- u32((is32bit() ? IMAGE_SCN_ALIGN_4BYTES : IMAGE_SCN_ALIGN_8BYTES) |
- IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
- IMAGE_SCN_MEM_WRITE)},
+ u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA |
+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)},
{{'.', 'i', 'd', 'a', 't', 'a', '$', '4'},
u32(0),
u32(0),
- u32(VASize),
+ u32(sizeof(export_address_table_entry)),
u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section) +
- VASize),
+ sizeof(export_address_table_entry)),
u32(0),
u32(0),
u16(0),
u16(0),
- u32((is32bit() ? IMAGE_SCN_ALIGN_4BYTES : IMAGE_SCN_ALIGN_8BYTES) |
- IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
- IMAGE_SCN_MEM_WRITE)},
+ u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA |
+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)},
};
append(Buffer, SectionTable);
- // .idata$5, ILT
- append(Buffer, u32(0));
- if (!is32bit())
- append(Buffer, u32(0));
+ // .idata$5
+ static const export_address_table_entry ILT{u32(0)};
+ append(Buffer, ILT);
- // .idata$4, IAT
- append(Buffer, u32(0));
- if (!is32bit())
- append(Buffer, u32(0));
+ // .idata$4
+ static const export_address_table_entry IAT{u32(0)};
+ append(Buffer, IAT);
// Symbol Table
coff_symbol16 SymbolTable[NumberOfSymbols] = {
@@ -463,7 +458,7 @@ void lld::coff::writeImportLibrary() {
std::vector<NewArchiveMember> Members;
std::string Path = getImplibPath();
- std::string DLLName = sys::path::filename(Config->OutputFile);
+ std::string DLLName = llvm::sys::path::filename(Config->OutputFile);
ObjectFactory OF(DLLName);
std::vector<uint8_t> ImportDescriptor;
diff --git a/gnu/llvm/tools/lld/COFF/ModuleDef.cpp b/gnu/llvm/tools/lld/COFF/ModuleDef.cpp
index a273b6f535d..5e393f45d18 100644
--- a/gnu/llvm/tools/lld/COFF/ModuleDef.cpp
+++ b/gnu/llvm/tools/lld/COFF/ModuleDef.cpp
@@ -18,7 +18,6 @@
#include "Config.h"
#include "Error.h"
-#include "Memory.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/StringSaver.h"
@@ -114,7 +113,7 @@ private:
class Parser {
public:
- explicit Parser(StringRef S) : Lex(S) {}
+ explicit Parser(StringRef S, StringSaver *A) : Lex(S), Alloc(A) {}
void parse() {
do {
@@ -198,9 +197,9 @@ private:
if (Config->Machine == I386) {
if (!isDecorated(E.Name))
- E.Name = Saver.save("_" + E.Name);
+ E.Name = Alloc->save("_" + E.Name);
if (!E.ExtName.empty() && !isDecorated(E.ExtName))
- E.ExtName = Saver.save("_" + E.ExtName);
+ E.ExtName = Alloc->save("_" + E.ExtName);
}
for (;;) {
@@ -279,11 +278,14 @@ private:
Lexer Lex;
Token Tok;
std::vector<Token> Stack;
+ StringSaver *Alloc;
};
} // anonymous namespace
-void parseModuleDefs(MemoryBufferRef MB) { Parser(MB.getBuffer()).parse(); }
+void parseModuleDefs(MemoryBufferRef MB, StringSaver *Alloc) {
+ Parser(MB.getBuffer(), Alloc).parse();
+}
} // namespace coff
} // namespace lld
diff --git a/gnu/llvm/tools/lld/include/lld/Core/Parallel.h b/gnu/llvm/tools/lld/include/lld/Core/Parallel.h
index f241453a4d3..2dde97d9e3f 100644
--- a/gnu/llvm/tools/lld/include/lld/Core/Parallel.h
+++ b/gnu/llvm/tools/lld/include/lld/Core/Parallel.h
@@ -121,7 +121,7 @@ public:
// Spawn all but one of the threads in another thread as spawning threads
// can take a while.
std::thread([&, threadCount] {
- for (size_t i = 1; i < threadCount; ++i) {
+ for (std::size_t i = 1; i < threadCount; ++i) {
std::thread([=] {
work();
}).detach();
@@ -270,65 +270,26 @@ template <class T> void parallel_sort(T *start, T *end) {
}
#if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
-template <class IterTy, class FuncTy>
-void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) {
- std::for_each(Begin, End, Fn);
-}
-
-template <class IndexTy, class FuncTy>
-void parallel_for(IndexTy Begin, IndexTy End, FuncTy Fn) {
- for (IndexTy I = Begin; I != End; ++I)
- Fn(I);
+template <class Iterator, class Func>
+void parallel_for_each(Iterator begin, Iterator end, Func func) {
+ std::for_each(begin, end, func);
}
#elif defined(_MSC_VER)
// Use ppl parallel_for_each on Windows.
-template <class IterTy, class FuncTy>
-void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) {
- concurrency::parallel_for_each(Begin, End, Fn);
-}
-
-template <class IndexTy, class FuncTy>
-void parallel_for(IndexTy Begin, IndexTy End, FuncTy Fn) {
- concurrency::parallel_for(Begin, End, Fn);
+template <class Iterator, class Func>
+void parallel_for_each(Iterator begin, Iterator end, Func func) {
+ concurrency::parallel_for_each(begin, end, func);
}
#else
-template <class IterTy, class FuncTy>
-void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) {
- // TaskGroup has a relatively high overhead, so we want to reduce
- // the number of spawn() calls. We'll create up to 1024 tasks here.
- // (Note that 1024 is an arbitrary number. This code probably needs
- // improving to take the number of available cores into account.)
- ptrdiff_t TaskSize = std::distance(Begin, End) / 1024;
- if (TaskSize == 0)
- TaskSize = 1;
-
- TaskGroup Tg;
- while (TaskSize <= std::distance(Begin, End)) {
- Tg.spawn([=, &Fn] { std::for_each(Begin, Begin + TaskSize, Fn); });
- Begin += TaskSize;
- }
- Tg.spawn([=, &Fn] { std::for_each(Begin, End, Fn); });
-}
-
-template <class IndexTy, class FuncTy>
-void parallel_for(IndexTy Begin, IndexTy End, FuncTy Fn) {
- ptrdiff_t TaskSize = (End - Begin) / 1024;
- if (TaskSize == 0)
- TaskSize = 1;
-
- TaskGroup Tg;
- IndexTy I = Begin;
- for (; I < End; I += TaskSize) {
- Tg.spawn([=, &Fn] {
- for (IndexTy J = I, E = I + TaskSize; J != E; ++J)
- Fn(J);
- });
- Begin += TaskSize;
+template <class Iterator, class Func>
+void parallel_for_each(Iterator begin, Iterator end, Func func) {
+ TaskGroup tg;
+ ptrdiff_t taskSize = 1024;
+ while (taskSize <= std::distance(begin, end)) {
+ tg.spawn([=, &func] { std::for_each(begin, begin + taskSize, func); });
+ begin += taskSize;
}
- Tg.spawn([=, &Fn] {
- for (IndexTy J = I; J < End; ++J)
- Fn(J);
- });
+ std::for_each(begin, end, func);
}
#endif
} // end namespace lld