summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/InputGraph.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove FileNode::parse.Rui Ueyama2015-01-151-21/+0
| | | | | | | FileNode::parse was just a forwarder to File::parse so we could remove that. Also removed dead code. llvm-svn: 226144
* Remove InputGraph::size().Rui Ueyama2015-01-151-8/+0
| | | | llvm-svn: 226140
* Re-commit r225766, r225767, r225769, r225814, r225816, r225829, and r225832.Rui Ueyama2015-01-151-83/+2
| | | | | | | 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-2/+83
| | | | | | | 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-30/+0
| | | | | | | | | | | | 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.Rui Ueyama2015-01-131-25/+8
| | | | | | | We can remove these methods because every InputElement has only one File. llvm-svn: 225816
* Replace vector<unique_ptr<File> with unique_ptr<File>.Rui Ueyama2015-01-131-2/+2
| | | | | | | Because each InputElement has exactly one File, we no longer have to use a vector to store pointers to Files. llvm-svn: 225814
* Remove dead code.Rui Ueyama2015-01-131-18/+0
| | | | | | | Now every InputElement has exactly one File in it, so "expand" method is now no-op. llvm-svn: 225769
* Remove InputGraph::registerObserver.Rui Ueyama2015-01-131-11/+2
| | | | | | | | | | | | PECOFF was the only user of the API, and the reason why we created the API is because, although the driver creates a list of input files, it has no knowledge on what files are being created. It was because everything was hidden behind the InputGraph abstraction. Now the driver knows what that's doing. We no longer need this indirection to get the file list being processed. llvm-svn: 225767
* Remove InputGraph::dump().Rui Ueyama2015-01-131-7/+0
| | | | | | This is dead code. llvm-svn: 225766
* Convert CoreInputGraph.Rui Ueyama2015-01-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a part of InputGraph cleanup to represent input files as a flat list of Files (and some meta-nodes for group etc.) We cannot achieve that goal in one gigantic patch, so I split the task into small steps as shown below. (Recap the progress so far: Currently InputGraph contains a list of InputElements. Each InputElement contain one File (that used to have multiple Files, but I eliminated that use case in r223867). Files are currently instantiated in Driver::link(), but I already made a change to separate file parsing from object instantiation (r224102), so we can safely instantiate Files when we need them, instead of wrapping a file with the wrapper class (FileNode class). InputGraph used to act like a generator class by interpreting groups by itself, but it's now just a container of a list of InputElements (r223867).) 1. Instantiate Files in the driver and wrap them with WrapperNode. WrapperNode is a temporary class that allows us to instantiate Files in the driver while keep using the current InputGraph data structure. This patch demonstrates how this step 1 looks like, using Core driver as an example. 2. Do the same thing for the other drivers. When step 2 is done, an InputGraph consists of GroupEnd objects or WrapperNodes each of which contains one File. Other types of FileNode subclasses are removed. 3. Replace InputGraph with std::vector<std::unique_ptr<InputElement>>. InputGraph is already just a container of list of InputElements, so this step removes that needless class. 4. Remove WrapperNode. We need some code cleanup between each step, because many classes do a bit odd things (e.g. InputGraph::getGroupSize()). I'll straight things up as I need to. llvm-svn: 225313
* Simplify InputGraph API.Rui Ueyama2014-12-141-11/+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
* Make File always take the ownership of a MemoryBuffer.Rui Ueyama2014-12-121-11/+0
| | | | | | | | | | | | | | The documentation of parseFile() said that "the resulting File object may take ownership of the MemoryBuffer." So, whether or not the ownership of a MemoryBuffer would be taken was not clear. A FileNode (a subclass of InputElement, which is being deprecated) keeps the ownership if a File doesn't take it. This patch makes File always take the ownership of a buffer. Buffers lifespan is not always the same as File instances. Files are able to deallocate buffers after parsing the contents. llvm-svn: 224113
* Re-commit r223330: Rewrite InputGraph's GroupRui Ueyama2014-12-101-33/+29
| | | | llvm-svn: 223867
* Revert "Rewrite InputGraph's Group"Rui Ueyama2014-12-041-29/+33
| | | | | | | | 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-33/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Subclass InputGraph to get darwin linker library semanticsNick Kledzik2014-10-211-0/+2
| | | | | | | | | | | | | | | | | | | The darwin linker operates differently than the gnu linker with respect to libraries. The darwin linker first links in all object files from the command line, then to resolve any remaining undefines, it repeatedly iterates over libraries on the command line until either all undefines are resolved or no undefines were resolved in the last pass. When Shankar made the InputGraph model, the plan for darwin was for the darwin driver to place all libraries in a group at the end of the InputGraph. Thus making the darwin model a subset of the gnu model. But it turns out that does not work because the driver cannot tell if a file is an object or library until it has been loaded, which happens later. This solution is to subclass InputGraph for darwin and just iterate the graph the way darwin linker needs. llvm-svn: 220330
* Sort include files according to convention.Shankar Easwaran2014-10-181-2/+0
| | | | llvm-svn: 220131
* Change the signature of insertElementAt and rename addInputElementFrontRui Ueyama2014-07-241-11/+4
| | | | | | | | | | insertElementAt(x, END) does the identical thing as addInputElement(x), so the only reasonable use of insertElementAt is to call it with the other possible argument, BEGIN. That means the second parameter of the function is just redundant. This patch is to remove the second parameter and rename the function accordingly. llvm-svn: 213821
* Remove all uses of llvm::function_ref from LLD.Rui Ueyama2014-07-171-1/+1
| | | | llvm-svn: 213313
* Use std::function instead of llvm::function_ref.Rui Ueyama2014-07-171-1/+1
| | | | llvm-svn: 213312
* Update for llvm api change.Rafael Espindola2014-07-061-3/+4
| | | | llvm-svn: 212407
* Don't import error_code into the lld namespace.Rafael Espindola2014-06-121-3/+3
| | | | llvm-svn: 210785
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-1/+1
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209948
* Add observers to Input GraphRui Ueyama2014-05-141-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | Make it possible to add observers to an Input Graph, so that files returned from an Input Graph can be examined before they are passed to Resolver. To implement some PE/COFF features we need to know all the symbols that *can* be solved, including ones in archive files that are not yet to be read. Currently, Resolver only maintains a set of symbols that are already read. It has no knowledge on symbols in skipped files in an archive file. There are many ways to implement that. I chose to apply the observer pattern here because it seems most non-intrusive. We don't want to mess up Resolver with architecture specific features. Even in PE/COFF, the feature that needs this mechanism is minor. So I chose not to modify Resolver, but add a hook to Input Graph. Differential Revision: http://reviews.llvm.org/D3735 llvm-svn: 208753
* Revert "temporary commit."Rui Ueyama2014-05-091-10/+3
| | | | | | This reverts accidental commit r208427. llvm-svn: 208433
* temporary commit.Rui Ueyama2014-05-091-3/+10
| | | | llvm-svn: 208427
* Simplify InputGraph::getNextFile. No functionality change.Rui Ueyama2014-05-071-20/+11
| | | | llvm-svn: 208256
* Expand nested input elements.Rui Ueyama2014-05-061-7/+5
| | | | | | | | Previously only the toplevel elements were expanded by expandElements(). Now we recursively call getReplacements() to expand input elements even if they are in, say, in a group. llvm-svn: 208144
* Don't return value rather than always returning true.Rui Ueyama2014-05-061-2/+1
| | | | | | | addInputElement() never fails, and no one checks its return value except tests. Let's simplify the signature. llvm-svn: 208109
* Use range-based for loop. No functionality change.Rui Ueyama2014-04-041-16/+9
| | | | llvm-svn: 205594
* Rename getInputGraph() and getNextFile().Rui Ueyama2014-04-041-3/+3
| | | | | | | | | 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
* Expand 'auto' that's hard for human to deduce its real type.Rui Ueyama2014-04-031-1/+1
| | | | llvm-svn: 205564
* Remove ordinals from Input Graph elements.Rui Ueyama2014-04-031-30/+0
| | | | | | | | | | | | | An ordinal is set to each child of Input Graph, but no one actually uses it. The only piece of code that gets ordinaly values is sortInputElements in InputGraph.cpp, but it does not actually do anything -- we assign ordinals in increasing order just before calling sort, so when sort is called it's already sorted. It's no-op. We can simply remove it. No functionality change. Differential Revision: http://llvm-reviews.chandlerc.com/D3270 llvm-svn: 205501
* Simplify communication between Resolver and Input Graph.Rui Ueyama2014-04-021-35/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Move nextFile() from LinkingContext to InputGraph.Rui Ueyama2014-04-021-0/+31
| | | | | | | | | | | | | | | | | 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
* Remove unused enum Position::ANY and third parameter of insertElementAt().Rui Ueyama2014-04-011-6/+7
| | | | | | | | | insertElementAt()'s third parameter is not only unused but also ignored if you pass Position::END. The actual meaning of the parameter was obscure. Differential Revision: http://llvm-reviews.chandlerc.com/D3256 llvm-svn: 205376
* Rename insertOneElementAt -> insertElementAt.Rui Ueyama2014-04-011-2/+2
| | | | | | | insertElementsAt() is removed, so "One" in insertOneElementAt() no longer make much sense. Rename it for brevity. llvm-svn: 205372
* Inline empty constructor.Rui Ueyama2014-04-011-5/+0
| | | | llvm-svn: 205366
* Greatly simplify InputGraph.Rui Ueyama2014-04-011-53/+8
| | | | | | | | | | | | | | | | | | | | | InputGraph has too many knobs and controls that are not being used. This patch is to remove dead code, unused features and a class. There are two things that worth noting, besides simple dead code removal: 1. ControlNode class is removed. We had it as the base class of Group class, but it provides no functionality particularly meaningful. We now have shallower class hierarchy that is easier to understand. 2. InputGraph provides a feature to replace a node with its internal data. It is being used to "expand" some type of node, such as a Linker Script node, with its actual files. We used to have two options when replacing it -- ExpandOnly or ExpandAndReplace. ExpandOnly was to expand it but not remove the node from the tree. There is no use of that option in the code, so it was a dead feature. Differential Revision: http://llvm-reviews.chandlerc.com/D3252 llvm-svn: 205363
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-131-4/+4
| | | | | | | | This results in some simplifications to the code where an OwningPtr had to be used with the previous api and then ownership moved to a unique_ptr for the rest of lld. llvm-svn: 203809
* [C++11] Add #include's for OwningPtr.Ahmed Charles2014-03-031-0/+1
| | | | | | Allows removing #include's in LLVM while switching to std::unique_ptr. llvm-svn: 202679
* Use getError instead of the error_code operator.Rafael Espindola2014-01-081-1/+1
| | | | llvm-svn: 198797
* Make SimpleFileNode inherit from FileNode.Joey Gouly2013-12-191-2/+1
| | | | | | This removes a lot of duplicated code. llvm-svn: 197751
* Make anonymous namespace as small as possible.Rui Ueyama2013-12-101-4/+2
| | | | | | Use of static is recommended by the style guide. llvm-svn: 196877
* [InputGraph] Add capability to process Hidden nodes.Shankar Easwaran2013-11-221-1/+5
| | | | | | | | | | Hidden nodes could be a result of expansion, where a flavor might decide to keep the node that we want to expand but discard it from being processed by the resolver. Verifies with unittests. llvm-svn: 195516
* [InputGraph] Expand InputGraph nodes.Shankar Easwaran2013-11-221-0/+32
| | | | | | | | | | | Flavors may like to expand InputGraph nodes, when a filenode after parsing results in more elements. One such example is while parsing GNU linker scripts. The linker scripts after parsing would result in a lot of filenodes and probably controlnodes too. Adds unittests to verify functionality. llvm-svn: 195515
* Move InputGraph from Driver to Core. LinkingContext depends on it.Michael J. Spencer2013-11-141-0/+178
llvm-svn: 194641
OpenPOWER on IntegriCloud