summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker/LinkModules.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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-041-6/+9
| | | | | | Also remove unused includes. llvm-svn: 181100
* This patch breaks up Wrap.h so that it does not have to include all of Filip Pizlo2013-05-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | the things, and renames it to CBindingWrapping.h. I also moved CBindingWrapping.h into Support/. This new file just contains the macros for defining different wrap/unwrap methods. The calls to those macros, as well as any custom wrap/unwrap definitions (like for array of Values for example), are put into corresponding C++ headers. Doing this required some #include surgery, since some .cpp files relied on the fact that including Wrap.h implicitly caused the inclusion of a bunch of other things. This also now means that the C++ headers will include their corresponding C API headers; for example Value.h must include llvm-c/Core.h. I think this is harmless, since the C API headers contain just external function declarations and some C types, so I don't believe there should be any nasty dependency issues here. llvm-svn: 180881
* Move C++ code out of the C headers and into either C++ headersEric Christopher2013-04-221-0/+1
| | | | | | | or the C++ files themselves. This enables people to use just a C compiler to interoperate with LLVM. llvm-svn: 180063
* Specutively revert r178130.Bill Wendling2013-03-271-44/+29
| | | | | | | | | | | | | | | | | | | This may be causing a failure on some buildbots: Referencing function in another module! tail call fastcc void @_ZL11EvaluateOpstPtRj(i16 zeroext %17, i16* %Vals, i32* %NumVals), !dbg !219 Referencing function in another module! tail call fastcc void @_ZL11EvaluateOpstPtRj(i16 zeroext %19, i16* %Vals, i32* %NumVals), !dbg !221 Broken module found, compilation aborted! Stack dump: 0. Running pass 'Function Pass Manager' on module 'ld-temp.o'. 1. Running pass 'Module Verifier' on function '@_ZL11EvaluateOpstPtRj' clang: error: unable to execute command: Illegal instruction: 4 clang: error: linker command failed due to signal (use -v to see invocation) <rdar://problem/13516485> llvm-svn: 178156
* Improve performance of LinkModules when linking with modules with large ↵James Molloy2013-03-271-29/+44
| | | | | | numbers of functions which link lazily. Instead of creating and destroying function prototypes irrespective of if they are used, only create them if they are used. llvm-svn: 178130
* The Linker interface has some dead code after the cleanup in r172749Eli Bendersky2013-03-191-1/+1
| | | | | | | (and possibly others). The attached patch removes it, and tries to update comments accordingly. llvm-svn: 177406
* Clean up out-of-date comments and some stray whitespaceEli Bendersky2013-03-081-1/+1
| | | | llvm-svn: 176729
* Add static cast to unsigned char whenever a character classification ↵Guy Benyei2013-02-121-1/+2
| | | | | | function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration. llvm-svn: 175006
* [IR] Add 'Append' and 'AppendUnique' module flag behaviors.Daniel Dunbar2013-01-161-0/+28
| | | | llvm-svn: 172659
* [Linker] Change module flag linking to be more extensible.Daniel Dunbar2013-01-161-133/+97
| | | | | | | | | | - Instead of computing a bunch of buckets of different flag types, just do an incremental link resolving conflicts as they arise. - This also has the advantage of making the link result deterministic and not dependent on map iteration order. llvm-svn: 172634
* [Linker] Drop asserts that are embedded in cast<> and now checked by the ↵Daniel Dunbar2013-01-151-11/+0
| | | | | | verifier. llvm-svn: 172550
* Fix a copy/paste error in the IR Linker, casting an ArrayType instead of a ↵Joey Gouly2013-01-101-1/+1
| | | | | | VectorType. llvm-svn: 172054
* Move TypeFinder.h into the IR tree, it clearly belongs with the IR library.Chandler Carruth2013-01-071-1/+1
| | | | llvm-svn: 171749
OpenPOWER on IntegriCloud