summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't ever call materializeAllPermanently during LTO.Rafael Espindola2014-10-241-21/+14
| | | | | | | | | | To do this, change the representation of lazy loaded functions. The previous representation cannot differentiate between a function whose body has been removed and one whose body hasn't been read from the .bc file. That means that in order to drop a function, the entire body had to be read. llvm-svn: 220580
* Merge alignment of common GlobalValue.Rafael Espindola2014-09-091-1/+10
| | | | | | Fixes pr20882. llvm-svn: 217455
* When merging two common GlobalValues, keep the largest.Rafael Espindola2014-09-091-2/+17
| | | | llvm-svn: 217451
* Move some logic to ModuleLinker::shouldLinkFromSource. NFC.Rafael Espindola2014-09-091-49/+51
| | | | llvm-svn: 217449
* Fix a use of an undefined value (the linkage).Rafael Espindola2014-09-091-0/+3
| | | | llvm-svn: 217445
* Prefer common over weak linkage when linking.Rafael Espindola2014-09-091-2/+3
| | | | | | This matches the behavior of ELF linkers. llvm-svn: 217443
* Simplify ModuleLinker::getLinkageResult. NFC.Rafael Espindola2014-09-091-25/+30
| | | | llvm-svn: 217441
* Fix pr20078.Rafael Espindola2014-09-051-5/+25
| | | | | | | When linking llvm.global_ctors with the optional third element we have to handle it specially and only copy the elements whose keys were also copied. llvm-svn: 217281
* Set comdats when lazily linking functions.Rafael Espindola2014-08-151-0/+5
| | | | | | | We were setting the comdat when functions were copied in the initial pass, but not when they were linked only when we found out that they are needed. llvm-svn: 215765
* Don't upgrade global constructors when reading bitcodeDuncan P. N. Exon Smith2014-08-121-0/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An optional third field was added to `llvm.global_ctors` (and `llvm.global_dtors`) in r209015. Most of the code has been changed to deal with both versions of the variables. Users of the C API might create either version, the helper functions in LLVM create the two-field version, and clang now creates the three-field version. However, the BitcodeReader was changed to always upgrade to the three-field version. This created an unnecessary inconsistency in the IR before/after serializing to bitcode. This commit resolves the inconsistency by making the third field truly optional (and not upgrading in the bitcode reader). Since `llvm-link` was relying on this upgrade code, rather than deleting it I've moved it into `ModuleLinker`, where it upgrades these arrays as necessary to resolve inconsistencies between modules. The ideal resolution would be to remove the 2-field version and make the third field required. I filed PR20506 to track that. I changed `test/Bitcode/upgrade-global-ctors.ll` to a negative test and duplicated the `llvm-link` check in `test/Linker/global_ctors.ll` to check both upgrade directions. Since I came across this as part of PR5680 (serializing use-list order), I've also added the missing `verify-uselistorder` RUN line to `test/Bitcode/metadata-2.ll`. llvm-svn: 215457
* IR: Print a newline when dumping TypesJustin Bogner2014-08-121-2/+2
| | | | | | | | | | | | Type::dump() doesn't print a newline, which makes for a poor experience in a debugger. This looks like it was an ommission considering Value::dump() two lines above, so I've changed Type to add a newline as well. Of the two in-tree callers, one added a newline anyway, and I've updated the other one to use Type::print instead. llvm-svn: 215421
* Fix use of uninitialized variable.Rafael Espindola2014-08-111-2/+6
| | | | | | | Fixes linking bitcode files that use the new style comdats for constructors with ones that don't. llvm-svn: 215364
* Use an early return. NFC.Rafael Espindola2014-08-111-8/+9
| | | | llvm-svn: 215363
* Include <tuple> to make buildbots happyDavid Majnemer2014-06-271-0/+1
| | | | llvm-svn: 211949
* IR: Add COMDATs to the IRDavid Majnemer2014-06-271-49/+243
| | | | | | | | | | | | | | | | This new IR facility allows us to represent the object-file semantic of a COMDAT group. COMDATs allow us to tie together sections and make the inclusion of one dependent on another. This is required to implement features like MS ABI VFTables and optimizing away certain kinds of initialization in C++. This functionality is only representable in COFF and ELF, Mach-O has no similar mechanism. Differential Revision: http://reviews.llvm.org/D4178 llvm-svn: 211920
* Replace some assert(0)'s with llvm_unreachable.Craig Topper2014-06-181-1/+1
| | | | llvm-svn: 211141
* Allow aliases to be unnamed_addr.Rafael Espindola2014-06-061-0/+4
| | | | | | | | | | | | | | | | | | Alias with unnamed_addr were in a strange state. It is stored in GlobalValue, the language reference talks about "unnamed_addr aliases" but the verifier was rejecting them. It seems natural to allow unnamed_addr in aliases: * It is a property of how it is accessed, not of the data itself. * It is perfectly possible to write code that depends on the address of an alias. This patch then makes unname_addr legal for aliases. One side effect is that the syntax changes for a corner case: In globals, unnamed_addr is now printed before the address space. llvm-svn: 210302
* Allow alias to point to an arbitrary ConstantExpr.Rafael Espindola2014-06-031-35/+7
| | | | | | | | | | | | | | | | | | | | | This patch changes GlobalAlias to point to an arbitrary ConstantExpr and it is up to MC (or the system assembler) to decide if that expression is valid or not. This reduces our ability to diagnose invalid uses and how early we can spot them, but it also lets us do things like @test5 = alias inttoptr(i32 sub (i32 ptrtoint (i32* @test2 to i32), i32 ptrtoint (i32* @bar to i32)) to i32*) An important implication of this patch is that the notion of aliased global doesn't exist any more. The alias has to encode the information needed to access it in its metadata (linkage, visibility, type, etc). Another consequence to notice is that getSection has to return a "const char *". It could return a NullTerminatedStringRef if there was such a thing, but when that was proposed the decision was to just uses "const char*" for that. llvm-svn: 210062
* Use create methods since msvc doesn't handle delegating constructors.Rafael Espindola2014-05-171-2/+3
| | | | llvm-svn: 209076
* Reduce abuse of default values in the GlobalAlias constructor.Rafael Espindola2014-05-171-3/+2
| | | | | | This is in preparation for adding an optional offset. llvm-svn: 209073
* Fix most of PR10367.Rafael Espindola2014-05-161-8/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the design of GlobalAlias so that it doesn't take a ConstantExpr anymore. It now points directly to a GlobalObject, but its type is independent of the aliasee type. To avoid changing all alias related tests in this patches, I kept the common syntax @foo = alias i32* @bar to mean the same as now. The cases that used to use cast now use the more general syntax @foo = alias i16, i32* @bar. Note that GlobalAlias now behaves a bit more like GlobalVariable. We know that its type is always a pointer, so we omit the '*'. For the bitcode, a nice surprise is that we were writing both identical types already, so the format change is minimal. Auto upgrade is handled by looking through the casts and no new fields are needed for now. New bitcode will simply have different types for Alias and Aliasee. One last interesting point in the patch is that replaceAllUsesWith becomes smart enough to avoid putting a ConstantExpr in the aliasee. This seems better than checking and updating every caller. A followup patch will delete getAliasedGlobal now that it is redundant. Another patch will add support for an explicit offset. llvm-svn: 209007
* Change the GlobalAlias constructor to look a bit more like GlobalVariable.Rafael Espindola2014-05-161-3/+4
| | | | | | | This is part of the fix for pr10367. A GlobalAlias always has a pointer type, so just have the constructor build the type. llvm-svn: 208983
* Split GlobalValue into GlobalValue and GlobalObject.Rafael Espindola2014-05-131-5/+5
| | | | | | | | | This allows code to statically accept a Function or a GlobalVariable, but not an alias. This is already a cleanup by itself IMHO, but the main reason for it is that it gives a lot more confidence that the refactoring to fix the design of GlobalAlias is correct. That will be a followup patch. llvm-svn: 208716
* Delete trailing whitespace.Rafael Espindola2014-05-091-98/+98
| | | | llvm-svn: 208416
* LTO: Assert visibility of local linkage when merging symbolsDuncan P. N. Exon Smith2014-05-071-0/+2
| | | | | | | | `ModuleLinker::getLinkageResult()` shouldn't create symbols with local linkage and non-default visibility -- in fact, symbols with local linkage shouldn't be merged at all. Assert to that effect. llvm-svn: 208262
* Be more strict about not calling setAlignment on global aliases.Rafael Espindola2014-05-061-3/+9
| | | | | | | The fact that GlobalAlias::setAlignment exists at all is a side effect of how the classes are organized, it should never be used. llvm-svn: 208094
* [C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper2014-04-151-12/+12
| | | | | | instead of comparing to nullptr. llvm-svn: 206252
* [Layering] Sink Linker.h into a Linker subdirectory to make itChandler Carruth2014-03-061-1/+1
| | | | | | consistent with every other sub-library header in LLVM. llvm-svn: 203065
* Improve LinkModules warningsJF Bastien2014-03-051-5/+9
| | | | | | | | Provide triple and data layout as well as module names (or empty string) when there's a mismatch. Differential Revision: http://llvm-reviews.chandlerc.com/D2971 llvm-svn: 203009
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-051-2/+2
| | | | | | class. llvm-svn: 202946
* Compare DataLayout by Value, not by pointer.Rafael Espindola2014-02-261-1/+1
| | | | | | | | This fixes spurious warnings in llvm-link about the datalayout not matching. Thanks to Zalman Stern for reporting the bug! llvm-svn: 202276
* Store a DataLayout in Module.Rafael Espindola2014-02-251-2/+2
| | | | | | | | | | | | | | Now that DataLayout is not a pass, store one in Module. Since the C API expects to be able to get a char* to the datalayout description, we have to keep a std::string somewhere. This patch keeps it in Module and also uses it to represent modules without a DataLayout. Once DataLayout is mandatory, we should probably move the string to DataLayout itself since it won't be necessary anymore to represent the special case of a module without a DataLayout. llvm-svn: 202190
* Set the SuppressWarnings option on tool level and propagate to the library.Eli Bendersky2014-02-201-12/+13
| | | | | | | | | | | | | The SuppressWarnings flag, unfortunately, isn't very useful for custom tools that want to use the LLVM module linker. So I'm changing it to a parameter of the Linker, and the flag itself moves to the llvm-link tool. For the time being as SuppressWarnings is pretty much the only "option" it seems reasonable to propagate it to Linker objects. If we end up with more options in the future, some sort of "struct collecting options" may be a better idea. llvm-svn: 201819
* Add a -suppress-warnings option to bitcode linking.Eli Bendersky2014-02-061-9/+22
| | | | llvm-svn: 200927
* Reapply r194218 with fix:Bill Wendling2014-01-161-4/+4
| | | | | | | | | | | | Move copying of global initializers below the cloning of functions. The BlockAddress doesn't have access to the correct basic blocks until the functions have been cloned. This causes the BlockAddress to point to the old values. Just wait until the functions have been cloned before copying the initializers. PR13163 llvm-svn: 199354
* Decouple dllexport/dllimport from linkageNico Rieck2014-01-141-7/+5
| | | | | | | | | | | | | | | | | | | Representing dllexport/dllimport as distinct linkage types prevents using these attributes on templates and inline functions. Instead of introducing further mixed linkage types to include linkonce and weak ODR, the old import/export linkage types are replaced with a new separate visibility-like specifier: define available_externally dllimport void @f() {} @Var = dllexport global i32 1, align 4 Linkage for dllexported globals and functions is now equal to their linkage without dllexport. Imported globals and functions must be either declarations with external linkage, or definitions with AvailableExternallyLinkage. llvm-svn: 199218
* Revert "Decouple dllexport/dllimport from linkage"Nico Rieck2014-01-141-5/+7
| | | | | | | | Revert this for now until I fix an issue in Clang with it. This reverts commit r199204. llvm-svn: 199207
* Decouple dllexport/dllimport from linkageNico Rieck2014-01-141-7/+5
| | | | | | | | | | | | | | | | | | | Representing dllexport/dllimport as distinct linkage types prevents using these attributes on templates and inline functions. Instead of introducing further mixed linkage types to include linkonce and weak ODR, the old import/export linkage types are replaced with a new separate visibility-like specifier: define available_externally dllimport void @f() {} @Var = dllexport global i32 1, align 4 Linkage for dllexported globals and functions is now equal to their linkage without dllexport. Imported globals and functions must be either declarations with external linkage, or definitions with AvailableExternallyLinkage. llvm-svn: 199204
* Revert "Move copying of global initializers below the cloning of functions."Adrian Prantl2013-11-091-4/+4
| | | | | | | | This would cause internal symbols that are only referenced by global initializers to be removed. This reverts commit 194219. llvm-svn: 194304
* Move copying of global initializers below the cloning of functions.Bill Wendling2013-11-071-4/+4
| | | | | | | | | | The BlockAddress doesn't have access to the correct basic blocks until the functions have been cloned. This causes the BlockAddress to point to the old values. Just wait until the functions have been cloned before copying the initializers. PR13163 llvm-svn: 194218
* Add a 'deleteModule' method to the Linker class.Bill Wendling2013-10-161-0/+5
| | | | | | | | This deletes the Module ivar instead of having the LTO code generater do it. It also sets the pointer to 'NULL', so that if it's used again it will abort quickly. llvm-svn: 192778
* Add missing #include's to cctype when using isdigit/alpha/etc.Will Dietz2013-10-121-0/+1
| | | | llvm-svn: 192519
* Implement function prefix data as an IR feature.Peter Collingbourne2013-09-161-1/+16
| | | | | | | | | Previous discussion: http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-July/063909.html Differential Revision: http://llvm-reviews.chandlerc.com/D1191 llvm-svn: 190773
* Error on linking appending globals with different unnamed_addr.Rafael Espindola2013-09-041-1/+5
| | | | llvm-svn: 189950
* Fix linking of unnamed_addr in functions.Rafael Espindola2013-09-041-1/+5
| | | | llvm-svn: 189945
* Fix linking of unnamed_addr.Rafael Espindola2013-09-041-2/+6
| | | | | | | | This was regression from r134829. When linking we have to be conservative. If one of the symbols has a significant address, then the result should have it too. llvm-svn: 189935
* Extend RemapInstruction and friends to take an optional new parameter, a ↵James Molloy2013-05-281-50/+77
| | | | | | | | ValueMaterializer. Extend LinkModules to pass a ValueMaterializer to RemapInstruction and friends to lazily create Functions for lazily linked globals. This is a big win when linking small modules with large (mostly unused) library modules. llvm-svn: 182776
* Fix a performance bug in the Linker.Rafael Espindola2013-05-041-11/+22
| | | | | | | | | | | | | Now that we hava a convinient place to keep it, remeber the set of identified structs as we merge modules. This speeds up the linking of all the bitcode files in clang with the gold plugin and -plugin-opt=emit-llvm (i.e., link only, no codegen) from 5:25 minutes to 13.6 seconds! Patch by Xiaofei Wan! llvm-svn: 181104
* Implement Linker::LinkModules with Linker::linkInModule.Rafael Espindola2013-05-041-8/+9
| | | | | | Flipping which one is the implementation will let us optimize linkInModule. llvm-svn: 181102
* Now that Linker.cpp is almost empty, merge it into LinkModules.cpp.Rafael Espindola2013-05-043-37/+9
| | | | | | Also remove unused includes. llvm-svn: 181100
OpenPOWER on IntegriCloud