summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/Resolver.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Re-commit r225766, r225767, r225769, r225814, r225816, r225829, and r225832.Rui Ueyama2015-01-151-28/+28
| | | | | | | These changes depended on r225674 and had been rolled back in r225859. Because r225674 has been re-submitted, it's safe to re-submit them. llvm-svn: 226132
* Revert "Convert other drivers to use WrapperNode" and subsequent commits.Rui Ueyama2015-01-141-28/+28
| | | | | | | r225764 broke a basic functionality on Mac OS. This change reverts r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832. llvm-svn: 225859
* Remove InputGraph::getNextFile().Rui Ueyama2015-01-131-28/+28
| | | | | | | | | | | | getNextFile used to have a complex logic to determine which file should be processed by the Resolver on next iteration. Now, it is just a sequential accessor to the internal array and provides no sensible feature. This patch also removes InputGraph::getGroupSize and InputGraph:: skipGroup to simplify the code. llvm-svn: 225832
* Simplify InputGraph API.Rui Ueyama2014-12-141-15/+11
| | | | | | | | | These member functions returns either no_more_files error or a File object. We could simply return a nullptr instead of a no_more_files. This function will be removed soon as a part of InputGraph cleanup. I had to do that step by step. llvm-svn: 224208
* Re-commit r223330: Rewrite InputGraph's GroupRui Ueyama2014-12-101-21/+53
| | | | llvm-svn: 223867
* Revert "Rewrite InputGraph's Group"Rui Ueyama2014-12-041-53/+21
| | | | | | | | This reverts commit r223330 because it broke Darwin and ELF linkers in a way that we couldn't have caught with the existing test cases. llvm-svn: 223373
* Rewrite InputGraph's GroupRui Ueyama2014-12-041-21/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The aim of this patch is to reduce the excessive abstraction from the InputGraph. We found that even a simple thing, such as sorting input files (Mach-O) or adding a new file to the input file list (PE/COFF), is nearly impossible with the InputGraph abstraction, because it hides too much information behind it. As a result, we invented complex interactions between components (e.g. notifyProgress() mechanism) and tricky code to work around that limitation. There were many occasions that we needed to write awkward code. This patch is a first step to make it cleaner. As a first step, this removes Group class from the InputGraph. The grouping feature is now directly handled by the Resolver. notifyProgress is removed since we no longer need that. I could have cleaned it up even more, but in order to keep the patch minimum, I focused on Group. SimpleFileNode class, a container of File objects, is now limited to have only one File. We shold have done this earlier. We used to allow putting multiple File objects to FileNode. Although SimpleFileNode usually has only one file, the Driver class actually used that capability. I modified the Driver class a bit, so that one FileNode is created for each input File. We should now probably remove SimpleFileNode and directly store File objects to the InputGraph in some way, because a container that can contain only one object is useless. This is a TODO. Mach-O input files are now sorted before they are passe to the Resolver. DarwinInputGraph class is no longer needed, so removed. PECOFF still has hacky code to add a new file to the input file list. This will be cleaned up in another patch. llvm-svn: 223330
* [mach-o] remove __compact_unwind atoms once __unwind_info has been generatedTim Northover2014-11-041-0/+7
| | | | | | | | | | The job of the CompactUnwind pass is to turn __compact_unwind data (and __eh_frame) into the compressed final form in __unwind_info. After it's done, the original atoms are no longer relevant and should be deleted (they cause problems during actual execution, quite apart from the fact that they're not needed). llvm-svn: 221301
* Sort include files according to convention.Shankar Easwaran2014-10-181-4/+2
| | | | llvm-svn: 220131
* [mach-o] Implement -demangle.Nick Kledzik2014-09-301-1/+2
| | | | | | | | | | | | | | The darwin linker has the -demangle option which directs it to demangle C++ (and soon Swift) mangled symbol names. Long term we need some Diagnostics object for formatting errors and warnings. But for now we have the Core linker just writing messages to llvm::errs(). So, to enable demangling, I changed the Resolver to call a LinkingContext method on the symbol name. To make this more interesting, the demangling code is done via __cxa_demangle() which is part of the C++ ABI, which is only supported on some platforms, so I had to conditionalize the code with the config generated HAVE_CXXABI_H. llvm-svn: 218718
* Use DenseMap::lookup. No functionality change.Rui Ueyama2014-09-261-4/+2
| | | | llvm-svn: 218554
* Fix crash bug on Windows.Rui Ueyama2014-09-261-2/+4
| | | | | | | Mutating the DenseMap here seems to cause the Windows executable to crash. Don't use operator[] to access possibly nonexistent key. llvm-svn: 218548
* [PECOFF] Support COMDAT associative sections.Rui Ueyama2014-06-171-1/+11
| | | | | | | | | | | | | | | | | | | COFF supports a feature similar to ELF's section groups. This patch implements it. In ELF, section groups are identified by their names, and they are treated somewhat differently from regular symbols. In COFF, the feature is realized in a more straightforward way. A section can have an annotation saying "if Nth section is linked, link this section too." I added a new reference type, kindAssociate. If a target atom is coalesced away, the referring atom is removed by Resolver, so that they are treated as a group. Differential Revision: http://reviews.llvm.org/D4028 llvm-svn: 211106
* Don't import error_code into the lld namespace.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210785
* Add SymbolTable::isCoalescedAwayRui Ueyama2014-06-051-21/+4
| | | | | | | isCoalescedAway(x) is faster than replacement(x) != x as the former does not follow the replacement atom chain. Also it's easier to use. llvm-svn: 210242
* Print error message in LinkOnce handler.Rui Ueyama2014-06-051-14/+12
| | | | | | Rather than outside of the handler function to make the code simple. llvm-svn: 210241
* Remove group-parent references.Rui Ueyama2014-06-031-2/+4
| | | | | | | | | | | | | | | | | | | Previously section groups are doubly linked to their children. That is, an atom representing a group has group-child references to its group contents, and content atoms also have group-parent references to the group atom. That relationship was invariant; if X has a group-child edge to Y, Y must have a group-parent edge to X. However we were not using group-parent references at all. The resolver only needs group-child edges. This patch simplifies the section group by removing the unused reverse edge. No functionality change intended. Differential Revision: http://reviews.llvm.org/D3945 llvm-svn: 210066
* Make dead-striping to handle reverse edges.Rui Ueyama2014-06-031-2/+17
| | | | | | | | | | | | | | | Layout-before edges are no longer used for layout, but they are still there for dead-stripping. If we would just remove them from code, LLD would wrongly remove live atoms that were referenced by layout-befores. This patch fixes the issue. Before dead-stripping, it scans all atoms to construct a reverse map for layout-after edges. Dead- stripping pass uses the map to traverse the graph. Differential Revision: http://reviews.llvm.org/D3986 llvm-svn: 210057
* Simplify markLive().Rui Ueyama2014-06-021-6/+5
| | | | | | | | Reference::target() never returns a nullptr, so NULL check is not needed and is more harmful than doing nothing. No functionality change. llvm-svn: 210008
* Fix regression introduced in r205566.Rui Ueyama2014-05-141-10/+11
| | | | | | | | | | | | | | | In r205566, I made a change to Resolver so that Resolver revisit only archive files in --start-group and --end-group pair. That's not correct, as it also has to revisit DSO files. This patch is to fix the issue. Added a test to demonstrate the fix. I confirmed that it succeeded before r205566, failed after r205566, and is ok with this patch. Differential Revision: http://reviews.llvm.org/D3734 llvm-svn: 208797
* Return the expression result directly.Rui Ueyama2014-05-021-3/+1
| | | | llvm-svn: 207878
* SymbolTable::size() returns an unsigned int.Rui Ueyama2014-04-041-1/+1
| | | | | | | It's better to use the same type rather than a fixed width integer type that may be different from the return type. llvm-svn: 205597
* Do not use temporary variables to pass them to forEachUndefines.Rui Ueyama2014-04-041-14/+13
| | | | | | So that it's obvious that we pass these callbacks only to forEachUndefines. llvm-svn: 205593
* Return a vector rather than mutating a given one.Rui Ueyama2014-04-041-8/+4
| | | | | | | | This is cleaner and as efficient as before. Differential Revision: http://llvm-reviews.chandlerc.com/D3284 llvm-svn: 205590
* Rename getInputGraph() and getNextFile().Rui Ueyama2014-04-041-6/+5
| | | | | | | | | Seems getSomething() is more common naming scheme than just a noun to get something, so renaming these members. Differential Revision: http://llvm-reviews.chandlerc.com/D3285 llvm-svn: 205589
* Minor cleanups.Rui Ueyama2014-04-031-7/+2
| | | | llvm-svn: 205578
* Do not check deadStripNever twice.Rui Ueyama2014-04-031-28/+8
| | | | | | | | | | Atoms with deadStripNever attribute has already been added to the dead strip root set at end of Resolver::doDefinedAtom, so no need to check it for each atom again. Differential Revision: http://llvm-reviews.chandlerc.com/D3282 llvm-svn: 205575
* Move code into a helper function.Rui Ueyama2014-04-031-19/+15
| | | | | | | Move code that always runs after doUndefinedAtom into doUndefinedAtom for readability. llvm-svn: 205574
* Minor cleanup.Rui Ueyama2014-04-031-9/+5
| | | | llvm-svn: 205570
* Simplify two if's.Rui Ueyama2014-04-031-5/+3
| | | | llvm-svn: 205569
* Fix comments.Rui Ueyama2014-04-031-1/+1
| | | | llvm-svn: 205568
* Early return.Rui Ueyama2014-04-031-7/+9
| | | | llvm-svn: 205567
* Fix ELFFileNode::resetNextIndex().Rui Ueyama2014-04-031-25/+16
| | | | | | | | | | | | | | | | | | | ELFLinkingContext has a method addUndefinedAtomsFromSharedLibrary(). The method is being used to skip a shared library within --start-group and --end-group if it's not the first iteration of the group. We have the same, incomplete mechanism to skip a shared library within a group too. That's implemented in ELFFileNode. It's intended to not return a shared library on the second or further iterations in the first place. This mechanism is preferred over addUndefinedAtomsFromSharedLibrary because the policy is implemented in Input Graph -- that's what Input Graph is for. This patch removes the dupluicate feature and fixes ELFFileNode. Differential Revision: http://llvm-reviews.chandlerc.com/D3280 llvm-svn: 205566
* Add empty() to atom_collection.Rui Ueyama2014-04-031-3/+3
| | | | | | | | | "x.empty()" is more idiomatic than "x.size() == 0". This patch is to add such method and use it in LLD. Differential Revision: http://llvm-reviews.chandlerc.com/D3279 llvm-svn: 205558
* Remove "this->".Rui Ueyama2014-04-031-10/+10
| | | | | | | For most member function calls we do not use "this->" in this file. Remove the rest for consistency. llvm-svn: 205550
* Simplify communication between Resolver and Input Graph.Rui Ueyama2014-04-021-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | Resolver is sending too much information to Input Graph than Input Graph actually needs. In order to collect the detailed information, which wouldn't be consumed by anyone, we have a good amount of code in Resolver, Input Graph and Input Elements. This patch is to simplify it. No functionality change. Specifically, this patch replaces ResolverState enum with a boolean value. The enum defines many bits to notify the progress about linking to Input Graph using bit masks, however, what Input Graph actually does is to compare a given value with 0. The details of the bit mask is simply being ignored, so the efforts to collect such data is wasted. This patch also changes the name of the notification interface from setResolverState to notifyProgress, to make it sounds more like message passing style. It's not a setter but something to notify of an update, so the new name should be more appropriate than before. Differential Revision: http://llvm-reviews.chandlerc.com/D3267 llvm-svn: 205463
* Remove dead code.Rui Ueyama2014-04-021-5/+0
| | | | llvm-svn: 205454
* s/llvm::dyn_cast/dyn_cast/Rui Ueyama2014-04-021-3/+3
| | | | llvm-svn: 205404
* Use cast<T> instead of dyn_cast<T>.Rui Ueyama2014-04-021-2/+2
| | | | llvm-svn: 205403
* Remove dead code.Rui Ueyama2014-04-021-6/+2
| | | | llvm-svn: 205401
* Remove dead code.Rui Ueyama2014-04-021-4/+0
| | | | llvm-svn: 205397
* Move nextFile() from LinkingContext to InputGraph.Rui Ueyama2014-04-021-3/+3
| | | | | | | | | | | | | | | | | LinkingContext and InputGraph are unnecessarily entangled. Most linker input file data, e.g. the vector containing input files, the next index of the input file, etc. are managed by InputGraph, but only the current input file is for no obvious reason managed by LinkingContext. This patch is to move code from LinkingContext to InputGraph to fix it. It's now clear who's reponsible for managing input file state, which is InputGraph, and LinkingContext is now free from that responsibility. It improves the readability as we now have fewer dependencies between classes. No functionality change. Differential Revision: http://llvm-reviews.chandlerc.com/D3259 llvm-svn: 205394
* [core] support .gnu.linkonce sectionsShankar Easwaran2014-04-011-6/+26
| | | | | | | | | | | | | | | | | | .gnu.linkonce sections are similar to section groups. They were supported before section groups existed and provided a way to resolve COMDAT sections using a different design. There are few implementations that use .gnu.linkonce sections to store simple floating point constants which doesnot require complex section group support but need a way to store only one copy of the floating point constant in a binary. .gnu.linkonce based symbol resolution achieves that. Review : http://llvm-reviews.chandlerc.com/D3242 llvm-svn: 205280
* Revert "[core] support .gnu.linkonce sections"Shankar Easwaran2014-03-311-23/+5
| | | | | | | | | This reverts commit 5d5ca72a7876c3dd3dd1db83dc6a0d74be9e2cd1. Discuss on a better design to raise error when there is a similar group with Gnu linkonce sections and COMDAT sections. llvm-svn: 205224
* [core] support .gnu.linkonce sectionsShankar Easwaran2014-03-311-5/+23
| | | | | | | | | | | .gnu.linkonce sections are similar to section groups. They were supported before section groups existed and provided a way to resolve COMDAT sections using a different design. There are few implementations that use .gnu.linkonce sections to store simple floating point constants which doesnot require complex section group support but need a way to store only one copy of the floating point constant. .gnu.linkonce based symbol resolution achieves that. llvm-svn: 205163
* [core] add SectionGroup supportShankar Easwaran2014-03-261-2/+23
| | | | | | Review : http://llvm-reviews.chandlerc.com/D3182 llvm-svn: 204830
* Fix odd titlecasing and spacing in an error message.Rui Ueyama2014-01-181-2/+2
| | | | llvm-svn: 199530
* Use auto for readability. No functionality change.Rui Ueyama2014-01-181-9/+8
| | | | llvm-svn: 199527
* Using "final" as a variable name is a bit confusing in C++11, so rename it.Rui Ueyama2014-01-181-2/+2
| | | | llvm-svn: 199526
* Use getError instead of the error_code operator.Rafael Espindola2014-01-081-2/+3
| | | | llvm-svn: 198797
OpenPOWER on IntegriCloud