summaryrefslogtreecommitdiffstats
path: root/lld/lib/Passes/LayoutPass.cpp
Commit message (Collapse)AuthorAgeFilesLines
* MachO: Move LayoutPass to MachO directory.Rui Ueyama2015-02-051-478/+0
| | | | | | | | | | | | | | | | | | | | | | The real user of the LayoutPass is now only Mach-O, so move that pass out of the common directory to Mach-O directory. "Core" architecture were using the LayoutPass. I modified that to use a simple OrderPass. I think no one actually have authority what feature should be in Core and what's not, but I believe the LayoutPass is not very suitable for Core. Before more code starts depending on the complex pass, it's better to remove that from Core. I could have simplified that pass because Mach-O is the only user of the LayoutPass. For example, the second parameter of the LayoutPass constructor can be converted from optional to mandatory. I didn't do that in this patch to keep it simple. I'll do in a followup patch. http://reviews.llvm.org/D7311 llvm-svn: 228341
* Remove kindInGroup reference.Rui Ueyama2015-01-271-71/+0
| | | | | | | | | | | | That kind of reference was used only in ELFFile, and the use of that reference there didn't seem to make sense. All test still pass (after adjusting symbol names) without that code. LLD is still be able to link LLD and Clang. Looks like we just don't need this. http://reviews.llvm.org/D7189 llvm-svn: 227259
* Use parallel_sort in the LayoutPass.Rui Ueyama2015-01-261-1/+2
| | | | | | | | | | Time to link lld using lld improved from 5.7s to 5.4s on Windows. It's not a significant improvement but not bad for one-line change. This patch includes a bug fix for Parallel.h as the original code uses operator< instead of a compare function there. llvm-svn: 227132
* [mach-o] Add support for -order_file optionNick Kledzik2014-11-071-7/+22
| | | | | | | | | | | The darwin linker lets you rearrange functions and data for better locality (less paging). You do this with the -order_file option which supplies a text file containing one symbol per line. Implementing this required a small change to LayoutPass to add a custom sorter hook. llvm-svn: 221545
* Sort include files according to convention.Shankar Easwaran2014-10-181-4/+2
| | | | llvm-svn: 220131
* Fixes wrong Twine uses in FileNode::errStr() and in LayoutPass.cppRui Ueyama2014-09-181-9/+10
| | | | | | Patch from Rafael Auler! llvm-svn: 218088
* Fix unsafe memory accessRui Ueyama2014-07-251-2/+11
| | | | | | | | | | | | | | The following expression m[i] = m[j] where m is a DenseMap and i != j is not safe. m[j] returns a reference, which would be invalidated when a rehashing occurs. If rehashing occurs to make room for m[i], m[j] becomes invalid, and that invalid reference would be used as the RHS value of the expression. llvm-svn: 213969
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-2/+2
| | | | | | | | | | definition below all of the header #include lines, LLD edition. IF you want to know more details about this, you can see the recent commits to Debug.h in LLVM. This is just the LLD segment of a cleanup I'm doing globally for this macro. llvm-svn: 206851
* Do not use layout-before to layout atoms.Rui Ueyama2014-03-271-74/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we use both layout-after and layout-before edges to specify atom orders in the resulting executable. We have a complex piece of code in LayoutPass.cpp to deal with both types of layout specifiers. (In the following description, I denote "Atom A having a layout-after edge to B" as "A -> B", and A's layout-before to B as "A => B".) However, that complexity is not really needed for this reason: If there are atoms such that A => B, B -> A is always satisifed, so using only layout- after relationships will yield the same result as the current code. Actually we have a piece of complex code that verifies that, for each A -> B, B => [ X => Y => ... => Z => ] A is satsified, where X, Y, ... Z are all zero-size atoms. We can get rid of the code from our codebase because layout- before is basically redundant. I think we can simplify the code for layout-after even more than this, but I want to just remove this pass for now for simplicity. Layout-before edges are still there for dead-stripping, so this change won't break it. We will remove layout-before in a followup patch once we fix the dead-stripping pass. Differential Revision: http://llvm-reviews.chandlerc.com/D3164 llvm-svn: 204966
* Use early continues to reduce nesting.Rui Ueyama2014-03-211-117/+120
| | | | llvm-svn: 204523
* [lld] Include reference kind in cycle detector debug outputNico Rieck2014-02-241-5/+15
| | | | | | | | This restores the debug output to how it was before r197727 broke it. This went undetected because the corresponding test was never run due to broken feature detection. llvm-svn: 202079
* Run clang-format on r197727.Rui Ueyama2013-12-201-1/+1
| | | | llvm-svn: 197788
* [lld] Introduce registry and Reference kind tupleNick Kledzik2013-12-191-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main changes are in: include/lld/Core/Reference.h include/lld/ReaderWriter/Reader.h Everything else is details to support the main change. 1) Registration based Readers Previously, lld had a tangled interdependency with all the Readers. It would have been impossible to make a streamlined linker (say for a JIT) which just supported one file format and one architecture (no yaml, no archives, etc). The old model also required a LinkingContext to read an object file, which would have made .o inspection tools awkward. The new model is that there is a global Registry object. You programmatically register the Readers you want with the registry object. Whenever you need to read/parse a file, you ask the registry to do it, and the registry tries each registered reader. For ease of use with the existing lld code base, there is one Registry object inside the LinkingContext object. 2) Changing kind value to be a tuple Beside Readers, the registry also keeps track of the mapping for Reference Kind values to and from strings. Along with that, this patch also fixes an ambiguity with the previous Reference::Kind values. The problem was that we wanted to reuse existing relocation type values as Reference::Kind values. But then how can the YAML write know how to convert a value to a string? The fix is to change the 32-bit Reference::Kind into a tuple with an 8-bit namespace (e.g. ELF, COFFF, etc), an 8-bit architecture (e.g. x86_64, PowerPC, etc), and a 16-bit value. This tuple system allows conversion to and from strings with no ambiguities. llvm-svn: 197727
* Style fixes. No functionality change.Rui Ueyama2013-12-101-11/+8
| | | | llvm-svn: 196883
* Move scattered debug functions into one #ifndef-guarded place.Rui Ueyama2013-12-091-110/+106
| | | | llvm-svn: 196741
* Fix -Wunused-function to unbreak buildbot.Rui Ueyama2013-12-081-0/+2
| | | | llvm-svn: 196716
* Move static member functions out of a class.Rui Ueyama2013-12-081-10/+10
| | | | | | | Because compare() and its heper functions no longer have to be members of LayoutPass class, we can remove it from the class. No functionality change. llvm-svn: 196715
* Optimize the layout pass.Rui Ueyama2013-12-081-30/+45
| | | | | | | | | | | | | | | | The comparator used in the layout pass has many calls of map::find(). Because std::sort runs the comparator N*log2(N) times, the maps are looked up with the same key again and again. The map lookup is not a very fast operation. It made the pass slow. This patch eliminates the duplicate map lookups using decorate-sort-undecorate idiom. The pass used to take 1.1 seconds when linking LLD with LLD on Windows, but it now takes only 0.3 seconds. Overall performance gain in that case is from 6.1 seconds to 5.2 seconds. Differential Revision: http://llvm-reviews.chandlerc.com/D2358 llvm-svn: 196714
* Fix "doesnot", "endsup" typos and "lets" grammar issuesAlp Toker2013-12-021-2/+2
| | | | llvm-svn: 196056
* Print a bit more information before aborting.Rui Ueyama2013-11-271-1/+2
| | | | llvm-svn: 195801
* Remove unnecessary namespace qualifier.Rui Ueyama2013-11-051-4/+4
| | | | llvm-svn: 194037
* Remove redundant std::move().Rui Ueyama2013-11-011-1/+1
| | | | llvm-svn: 193883
* [PassManager] add ReaderWriter{Native,YAML} to the Driver.Shankar Easwaran2013-10-291-4/+3
| | | | | | | | | | | | | Enable this for the following flavors a) core b) gnu c) darwin Its disabled for the flavor PECOFF. Convenient markers are added with FIXME comments in the Driver that would be removed and code removed from each flavor. llvm-svn: 193585
* Revert "r193300 - [PassManager] add ReaderWriter{Native, YAML} to the Driver"Rui Ueyama2013-10-241-2/+2
| | | | | | | The patch have completely broken COFF port and disabled many tests. This also reverts r193302 (comment fix). llvm-svn: 193362
* [PassManager] add ReaderWriter{Native,YAML} to the Driver.Shankar Easwaran2013-10-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Disable tests to be run with REQUIRES: disable. Note disable is not added to the config by the test runner Mkaefiles, so essentially disables the test. Code changes would be required to fix these tests :- test/darwin/hello-world.objtxt test/elf/check.test test/elf/phdr.test test/elf/ppc.test test/elf/undef-from-main-dso.test test/elf/X86_64/note-sections-ro_plus_rw.test test/pecoff/alignment.test test/pecoff/base-reloc.test test/pecoff/bss-section.test test/pecoff/drectve.test test/pecoff/dynamic.test test/pecoff/dynamicbase.test test/pecoff/entry.test test/pecoff/hello.test test/pecoff/imagebase.test test/pecoff/importlib.test test/pecoff/lib.test test/pecoff/multi.test test/pecoff/reloc.test test/pecoff/weak-external.test llvm-svn: 193300
* Fix bug that CompareAtoms::compare is not transitive.Rui Ueyama2013-10-191-23/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a bug in r190608. The results of a comparison function passed to std::sort must be transitive, which is, if a < b and b < c, and if a != b, a < c must be also true. CompareAtoms::compare did not actually guarantee the transitivity. As a result the sort results were sometimes just wrong. Consider there are three atoms, X, Y, and Z, whose file ordinals are 1, 2, 3, respectively. Z has a property "layout-after X". In this case, all the following conditionals become true: X < Y because X's ordinal is less than Y's Y < Z because Y's ordinal is less than Z's Z < X because of the layout-after relationship This is not of course transitive. The reason why this happened is because we used follow-on relationships for comparison if two atoms falls in the same follow-on chain, but we used each atom's properties if they did not. This patch fixes the issue by using follow-on root atoms for comparison to get consistent results. Differential Revision: http://llvm-reviews.chandlerc.com/D1980 llvm-svn: 193029
* Fix -Wunused-function warning of release build.Rui Ueyama2013-10-181-0/+2
| | | | llvm-svn: 192943
* Fix a layout pass debug message.Rui Ueyama2013-10-181-1/+1
| | | | llvm-svn: 192942
* Improve debug message of the layout pass.Rui Ueyama2013-10-181-29/+46
| | | | | | | | | | | | | | | | | | | | | Instead of showing multiple lines of debug messages, show only one message by CompareAtoms::operator(). Here is an example. Before: Sorting _main .text Sorting by sectionPos(2,2) Sorting by override Sorting _main .text Sorting by sectionPos(2,2) Sorting by override After: Layout: '_main' > '.text' (override (1, 0)) Layout: '_main' > '.text' (override (1, 0)) Differential Revision: http://llvm-reviews.chandlerc.com/D1964 llvm-svn: 192941
* Fix return after llvm_unreachableShankar Easwaran2013-10-111-2/+0
| | | | llvm-svn: 192414
* [ELF] Fix Atoms in the same file had overlapping ordinals.Shankar Easwaran2013-10-111-1/+3
| | | | | | | This also reverts the LayoutPass to use std::sort as all files have an ordinal now. llvm-svn: 192409
* [Core] Fix unstable sort for unordered atoms.Michael J. Spencer2013-10-031-1/+1
| | | | llvm-svn: 191867
* [Core] Fix heap overflow in LayoutPass.Michael J. Spencer2013-10-021-3/+5
| | | | | | | Found this with asan. Code assumes that find doesn't return end, thus if both atoms didn't have followon roots it would still compare their positions. llvm-svn: 191865
* [lld][LayoutPass] change comments to reflect the sort orderShankar Easwaran2013-09-121-4/+5
| | | | llvm-svn: 190612
* [lld][LayoutPass] Order the atoms that are in the same chainShankar Easwaran2013-09-121-20/+9
| | | | | | | | | | | We need to order atoms that exist in the same chain. This is to make sure that the command line order is preserved when we emit the atoms to the output file. Credits: BigCheese for finding the bug. Adds a test which otherwise would fail. llvm-svn: 190608
* Fix test failure introduced in r187271 by enabling pipefail.Rui Ueyama2013-07-291-1/+1
| | | | llvm-svn: 187381
* [LayoutPass] Add a method to check the followon graph structure.Rui Ueyama2013-06-071-17/+119
| | | | | | | | | | | | | | | Found that having a method to check the strucutre of the followon graph makes it easy to debug file readers. The method checks if there's no wrong edge in followOnNexts and followOnRoots. It is called only when debuggging is enabled for LayoutPass. Reviewers: shankarke CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D922 llvm-svn: 183553
* Revert "[Passes] Parallelize the layout pass sort."Michael J. Spencer2013-05-311-2/+1
| | | | | | Inconsistent (and wrong) sort order on non-Windows. llvm-svn: 182975
* [Passes] Parallelize the layout pass sort.Michael J. Spencer2013-05-281-2/+3
| | | | llvm-svn: 182792
* Instrument things.Michael J. Spencer2013-05-281-0/+1
| | | | llvm-svn: 182789
* [lld][LayoutPass] Consolidate debug flags, removing "layout" flag.Rui Ueyama2013-05-231-4/+2
| | | | | | | | | | | | | DEBUG_TYPE is already defined at the beginning of this file. We don't want to have two different debug flags for a single pass. Reviewers: shankarke CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D845 llvm-svn: 182543
* [lld][LayoutPass] An earlier commit moved the functionality so that Atoms wouldShankar Easwaran2013-05-221-15/+15
| | | | | | | | | | | | | | | | | | | be laid out by their ordinal overrides first, there was a bug that two atoms may get the same override index due to which atoms were not ordered properly. This commit fixes the problem. Now the atoms are ordered by - Section Position hints - Atom override (Using layout-after/layout-before/in-group) - Content Permissions - Content Type - File Ordinal This also fixes the problem of running c++ static executables that was broken by an earlier patch. llvm-svn: 182494
* [lld][LayoutPass] Cleanup: replace (*atom).size() with atom->size().Rui Ueyama2013-05-141-6/+6
| | | | llvm-svn: 181804
* [lld][LayoutPass] Fix a bug that caused buildbot to fail on some platforms.Rui Ueyama2013-05-141-3/+4
| | | | llvm-svn: 181752
* [lld][LayoutPass] Split buildFollowOnTable for readability.Rui Ueyama2013-05-141-137/+102
| | | | | | | | | | | | | Summary: Split buildFollowOnTable to small functions to improve code readability and remove code duplication. No change in functionality. CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D790 llvm-svn: 181749
* [lld][LayoutPass] This commit fixes a problem in theShankar Easwaran2013-05-101-24/+24
| | | | | | | | | | | | | | Layoutpass by ordering atoms if they appear in the override list first and then looking at the way of ordering atoms in the default way. The fix also fixes issues with the sizes of the sections, that appear in the output properly too. The commit also adds a testcase(orderatoms-by-override.test) to test it and fixes all the other relevant testcases. llvm-svn: 181605
* [lld][LayoutPass] initialize the number of entries for the densehash (no ↵Shankar Easwaran2013-04-291-18/+23
| | | | | | functionality change) llvm-svn: 180690
* Add VTune as an optional external dependency and add task tracking.Michael J. Spencer2013-04-061-1/+6
| | | | llvm-svn: 178940
* fix DEBUG_WITH_TYPE to build without warnings in non-debug buildsNick Kledzik2013-04-041-13/+16
| | | | llvm-svn: 178787
* This is my Driver refactoring patch. Nick Kledzik2013-04-041-0/+24
| | | | | | | | | | | | | | | | | | | | | | | The major changes are: 1) LinkerOptions has been merged into TargetInfo 2) LinkerInvocation has been merged into Driver 3) Drivers no longer convert arguments into an intermediate (core) argument list, but instead create a TargetInfo object and call setter methods on it. This is only how in-process linking would work. That is, you can programmatically set up a TargetInfo object which controls the linking. 4) Lots of tweaks to test suite to work with driver changes 5) Add the DarwinDriver 6) I heavily doxygen commented TargetInfo.h Things to do after this patch is committed: a) Consider renaming TargetInfo, given its new roll. b) Consider pulling the list of input files out of TargetInfo. This will enable in-process clients to create one TargetInfo the re-use it with different input file lists. c) Work out a way for Drivers to format the warnings and error done in core linking. llvm-svn: 178776
OpenPOWER on IntegriCloud