summaryrefslogtreecommitdiffstats
path: root/lld/COFF/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove unnecessary explicit call of Twine ctor.Rui Ueyama2016-07-151-2/+2
| | | | llvm-svn: 275512
* COFF: Rename noreturn error -> fatal.Rui Ueyama2016-07-141-6/+6
| | | | | | This new name is also consistent with ELF. llvm-svn: 275500
* COFF: Update remaining #include paths.Peter Collingbourne2016-07-141-1/+1
| | | | llvm-svn: 275480
* Update for llvm change.Rafael Espindola2016-05-261-3/+7
| | | | llvm-svn: 270907
* Do not use llvm::getGlobalContext().Rui Ueyama2016-04-141-1/+1
| | | | llvm-svn: 266375
* Revert "Do not use llvm::getGlobalContext(), trying to nuke it from LLVM"Mehdi Amini2016-04-141-2/+1
| | | | | | | | This reverts commit r266365 and r266367, the contexts in the two places have to match. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266373
* Do not use llvm::getGlobalContext(), trying to nuke it from LLVMMehdi Amini2016-04-141-1/+2
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266365
* [COFF] Simplify the code leveraging implicit conversion.Davide Italiano2016-04-121-2/+1
| | | | | | Suggested by: David Blaikie! llvm-svn: 266140
* [COFF] SmallVector<char, 0> -> SmallString<0>.Davide Italiano2016-04-091-2/+2
| | | | | | This way we're consistent between ELF and COFF. llvm-svn: 265885
* Update for LLVM api change.Rafael Espindola2015-12-041-1/+2
| | | | llvm-svn: 254697
* COFF: Destroy LTOModules as they are linked.Peter Collingbourne2015-11-171-1/+1
| | | | | | | | This should help reduce memory consumption during LTO. Differential Revision: http://reviews.llvm.org/D14672 llvm-svn: 253397
* Fixing build failures caused by r253367. Sorry for breaking the build.Yunzhong Gao2015-11-171-5/+4
| | | | llvm-svn: 253374
* COFF: Do not call std::async with std::launch::async if multithreading is ↵Rui Ueyama2015-09-211-2/+8
| | | | | | disabled. llvm-svn: 248193
* COFF: Run InputFile::parse() in background using std::async().Rui Ueyama2015-09-201-24/+20
| | | | | | | | | | | | | | | Previously, InputFile::parse() was run in batch. We construct a list of all input files and call parse() on each file using parallel_for_each. That means we cannot start parsing files until we get a complete list of input files, although InputFile::parse() is safe to call from anywhere. This patch makes it asynchronous. As soon as we add a file to the symbol table, we now start parsing the file using std::async(). This change shortens self-hosting time (650 ms) by 28 ms. It's about 4% improvement. llvm-svn: 248109
* COFF: Change Symbol::Body type from atomic pointer to regular pointer.Rui Ueyama2015-09-201-41/+32
| | | | | | | | I made the field an atomic pointer in hope that we would be able to parallelize the symbol resolver soon, but that's not going to happen soon. This patch reverts that change for the sake of readability. llvm-svn: 248104
* COFF: Actually parallelize InputFile::parse().Rui Ueyama2015-09-191-4/+4
| | | | | | This is a follow-up patch to r248078. llvm-svn: 248098
* Remove unused #includes.Rui Ueyama2015-09-191-1/+0
| | | | llvm-svn: 248081
* COFF: Parallelize InputFile::parse().Rui Ueyama2015-09-191-16/+22
| | | | | | | | | | | | | | | | | | | | | | | InputFile::parse() can be called in parallel with other calls of the same function. By doing that, time to self-link improves from 741 ms to 654 ms or 12% faster. This is probably the last low hanging fruit in terms of parallelism. Input file parsing and symbol table insertion takes 450 ms in total. If we want to optimize further, we probably have to parallelize symbol table insertion using concurrent hashmap or something. That's doable, but that's not easy, especially if you want to keep the exact same semantics and linking order. I'm not going to do that at least soon. Anyway, compared to r248019 (the change before the first attempt for parallelism), we achieved 36% performance improvement from 1022 ms to 654 ms. MSVC linker takes 3.3 seconds to link the same program. MSVC's ICF feature is very slow for some reason, but even if we disable the feature, it still takes about 1.2 seconds. Our number is probably good enough. llvm-svn: 248078
* Enable extra LTO verification only when build type is debug.Rui Ueyama2015-09-171-1/+5
| | | | llvm-svn: 247956
* COFF: Remove DefinedSymbol::isLive() and markLive(). NFC.Rui Ueyama2015-09-161-1/+1
| | | | | | | | | | | | | Basically the concept of "liveness" is for sections (or chunks in LLD terminology) and not for symbols. Symbols are always available or live, or otherwise it indicates a link failure. Previously, we had isLive() and markLive() methods for DefinedSymbol. They are confusing methods. What they actually did is to act as a proxy to backing section chunks. We can simplify eliminate these methods and call section chunk's methods directly. llvm-svn: 247869
* LTO: Adjust to LLVM r247735Duncan P. N. Exon Smith2015-09-151-1/+1
| | | | | | | Perhaps lld wants to disable the verifier sometimes during COFF LTO, but for now just match behaviour from before r247735. llvm-svn: 247736
* Remove an allocator which was used for just one allocation.Rafael Espindola2015-09-021-2/+2
| | | | llvm-svn: 246662
* COFF: Implement parallel LTO code generation.Peter Collingbourne2015-08-281-24/+47
| | | | | | | | | This is exposed via a new flag /opt:lldltojobs=N, where N is the number of code generation threads. Differential Revision: http://reviews.llvm.org/D12309 llvm-svn: 246342
* COFF: Update for LTO API change.Peter Collingbourne2015-08-241-1/+1
| | | | llvm-svn: 245892
* COFF: Fix /lldmap option.Rui Ueyama2015-08-211-1/+1
| | | | | | isLive returns false if it's not COMDAT, so check for that condition. llvm-svn: 245676
* COFF: Introduce flag /opt:lldlto=N for controlling LTO optimization level.Peter Collingbourne2015-08-141-0/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D12024 llvm-svn: 245027
* Port the error functions from ELF to COFF.Rafael Espindola2015-08-061-77/+47
| | | | | | | | | | | | | | | This has a few advantages * Less C++ code (about 300 lines less). * Less machine code (about 14 KB of text on a linux x86_64 build). * It is more debugger friendly. Just set a breakpoint on the exit function and you get the complete lld stack trace of when the error was found. * It is a more robust API. The errors are handled early and we don't get a std::error_code hot potato being passed around. * In most cases the error function in a better position to print diagnostics (it has more context). llvm-svn: 244215
* COFF: _tls_used is __tls_used on x86.Rui Ueyama2015-07-281-0/+6
| | | | llvm-svn: 243495
* COFF: Use short identifiers. NFC.Rui Ueyama2015-07-251-1/+1
| | | | llvm-svn: 243229
* COFF: Don't assume !is64() means i386.Rui Ueyama2015-07-251-1/+1
| | | | | | | | In many places we assumed that is64() means AMD64 and i386 otherwise. This assumption is not sound because Windows also supports ARM. The linker doesn't support ARM yet, but this is a first step. llvm-svn: 243188
* COFF: Implement Safe SEH support for x86.Rui Ueyama2015-07-241-2/+10
| | | | | | | | | | | | | An object file compatible with Safe SEH contains a .sxdata section. The section contains a list of symbol table indices, each of which is an exception handler function. A safe SEH-enabled executable contains a list of exception handler RVAs. So, what the linker has to do to support Safe SEH is basically to read the .sxdata section, interpret the contents as a list of symbol indices, unique-fy and sort their RVAs, and then emit that list to .rdata. This patch implements that feature. llvm-svn: 243182
* COFF: Fix __ImageBase symbol relocation.Rui Ueyama2015-07-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | __ImageBase is a special symbol whose value is the image base address. Previously, we handled __ImageBase symbol as an absolute symbol. Absolute symbols point to specific locations in memory and the locations never change even if an image is base-relocated. That means that we don't have base relocation entries for absolute symbols. This is not a case for __ImageBase. If an image is base-relocated, its base address changes, and __ImageBase needs to be shifted as well. So we have to have base relocations for __ImageBase. That means that __ImageBase is not really an absolute symbol but a different kind of symbol. In this patch, I introduced a new type of symbol -- DefinedRelative. DefinedRelative is similar to DefinedAbsolute, but it has not a VA but RVA and is a subject of base relocation. Currently only __ImageBase is of the new symbol type. llvm-svn: 243176
* COFF: Fix entry name inference for x86.Rui Ueyama2015-07-141-17/+28
| | | | | | | | | | | Entry name selection rule is already complicated on x64, but it's more complicated on x86 because of the underscore name mangling scheme. If one of _main, _main@<number> (a C function) or ?main@@... (a C++ function) is defined, entry name is _mainCRTStartup. If _wmain, _wmain@<number or ?wmain@@... is defined, entry name is _wmainCRTStartup. And so on. llvm-svn: 242110
* COFF: Find C++ mangled name for symbols starting with underscore.Rui Ueyama2015-07-091-1/+8
| | | | | | | | Symbol foo is mangled as _foo in C and ?foo@@... in C++ on x86. findMangle has to remove prefix underscore before mangle a given name as a C++ symbol. llvm-svn: 241874
* COFF: Improve undefined symbol diagnostics.Peter Collingbourne2015-07-071-9/+16
| | | | | | | | We now report the names of any files containing undefined symbol references. Differential Revision: http://reviews.llvm.org/D10982 llvm-svn: 241612
* COFF: Fix bug involving archives defining a symbol multiple times.Peter Collingbourne2015-07-071-1/+2
| | | | | | | | | | | Previously we were unnecessarily loading lazy symbols if they appeared in an archive multiple times, as can happen with comdat symbols. This change fixes the bug by only loading symbols from archives at load time if the original symbol was undefined. Differential Revision: http://reviews.llvm.org/D10980 llvm-svn: 241538
* COFF: Support isa<> for Symbol::Body, whose type is std::atomic<SymbolBody *>.Rui Ueyama2015-07-061-6/+6
| | | | llvm-svn: 241477
* COFF: Use CAS to update Sym->Body.Rui Ueyama2015-07-051-29/+41
| | | | | | | Note that the linker is not multi-threaded yet. This is a preparation for that. llvm-svn: 241417
* COFF: Use atomic pointers in preparation for parallelizing.Rui Ueyama2015-07-051-6/+6
| | | | | | | | | | | | | In the new design, mutation of Symbol pointers is the name resolution operation. This patch makes them atomic pointers so that they can be mutated by multiple threads safely. I'm going to use atomic compare-exchange on these pointers. dyn_cast<> doesn't recognize atomic pointers as pointers, so we need to call load(). This is unfortunate, but in other places automatic type conversion works fine. llvm-svn: 241416
* COFF: Numerous fixes for interaction between LTO and weak externals.Peter Collingbourne2015-07-041-27/+23
| | | | | | | | | | | | | | | | | | | | We were previously hitting assertion failures in the writer in cases where a regular object file defined a weak external symbol that was defined by a bitcode file. Because /export and /entry name mangling were implemented using weak externals, the same problem affected mangled symbol names in bitcode files. The underlying cause of the problem was that weak external symbols were being resolved before doing LTO, so the symbol table may have contained stale references to bitcode symbols. The fix here is to defer weak external symbol resolution until after LTO. Also implement support for weak external symbols in bitcode files by modelling them as replaceable DefinedBitcode symbols. Differential Revision: http://reviews.llvm.org/D10940 llvm-svn: 241391
* COFF: Print directive section contents if /verbose.Rui Ueyama2015-07-041-1/+5
| | | | llvm-svn: 241384
* COFF: Fix the case where an object defines a weak external and its alias.Peter Collingbourne2015-07-031-4/+5
| | | | | | | | | | This worked before, but only by accident, and only with assertions disabled. We ended up storing a DefinedRegular symbol in the WeakAlias field, and never using it as an Undefined. Differential Revision: http://reviews.llvm.org/D10934 llvm-svn: 241376
* COFF: Fix /base option.Rui Ueyama2015-07-031-4/+4
| | | | | | | | | | | Previously, __ImageBase symbol got a different value than the one specified by /base:<number> because the symbol was created in the SymbolTable's constructor. When the constructor is called, no command line options are processed yet, so the symbol was created always with the initial value. This caused wrong relocations and thus caused mysterious crashes of some executables linked by LLD. llvm-svn: 241313
* COFF: Define SymbolTable::insert to simplify. NFC.Rui Ueyama2015-07-021-22/+20
| | | | llvm-svn: 241311
* COFF: Merge SymbolTable::find{,Symbol}. NFCRui Ueyama2015-07-021-12/+5
| | | | llvm-svn: 241238
* COFF: Infer entry point as early as possible, but not too early.Rui Ueyama2015-07-021-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | On Windows, we have four different main functions, {w,}{main,WinMain}. The linker has to choose a corresponding entry point function among {w,}{main,WinMain}CRTStartup. These entry point functions are defined in the standard library. The linker resolves one of them by looking at which main function is defined and adding a corresponding undefined symbol to the symbol table. Object files containing entry point functions conflicts each other. For example, we cannot resolve both mainCRTStartup and WinMainCRTStartup because other symbols defined in the files conflict. Previously, we inferred CRT function name at the very end of name resolution. I found that that is sometimes too late. If the linker already linked one of these four archive member objects, it's too late to change the decision. The right thing to do here is to infer entry point name after adding all symbols from command line files and before adding any other files (which are specified by directive sections). This patch does that. llvm-svn: 241236
* COFF: Resolve AlternateNames using weak aliases.Rui Ueyama2015-07-021-37/+19
| | | | | | | | Previously, we use SymbolTable::rename to resolve AlternateName symbols. This patch is to merge that mechanism with weak aliases, so that we remove that function. llvm-svn: 241230
* COFF: Rename getReplacement -> repl.Rui Ueyama2015-07-021-7/+6
| | | | | | The previous name was too long to my taste. llvm-svn: 241215
* COFF: Change GCRoot member type from StringRef to Undefined. NFC.Rui Ueyama2015-07-021-3/+3
| | | | | | | | | I think Undefined symbols are a bit more convenient than StringRefs since SymbolBodies are handles for symbols. You can get resolved symbols for undefined symbols just by calling getReplacmenet without looking up the symbol table. llvm-svn: 241214
* COFF: Simplify and rename findMangle. NFC.Rui Ueyama2015-07-021-24/+20
| | | | | | | | | | Occasionally we have to resolve an undefined symbol to its mangled symbol. Previously, we did that on calling side of findMangle by explicitly updating SymbolBody. In this patch, mangled symbols are handled as weak aliases for undefined symbols. llvm-svn: 241213
OpenPOWER on IntegriCloud