summaryrefslogtreecommitdiffstats
path: root/llvm/tools/gold/gold-plugin.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use raw_fd_ostream instead of std::ofstream.Rafael Espindola2014-07-071-11/+9
| | | | llvm-svn: 212483
* Update the MemoryBuffer API to use ErrorOr.Rafael Espindola2014-07-061-3/+6
| | | | llvm-svn: 212405
* Declare variable on first use.Rafael Espindola2014-07-061-5/+5
| | | | llvm-svn: 212403
* gold plugin: move target initialization to the top of the onload function.Peter Collingbourne2014-07-031-5/+6
| | | | | | | | | | On at least my machine, ar does not register an all symbols read hook (which previously triggered target initialization), but it does register a claim files hook, which depends on the targets being initialized. Differential Revision: http://reviews.llvm.org/D4372 llvm-svn: 212303
* LTO: rename the various makeLTOModule overloads.Peter Collingbourne2014-07-031-1/+1
| | | | | | | | | This rename makes it easier to identify the specific overload being called in each particular case and makes future refactorings easier. Differential Revision: http://reviews.llvm.org/D4370 llvm-svn: 212302
* Fix the new LTOCodeGenerator setup in gold to parse options before using MAttrs.Tom Roeder2014-06-261-9/+10
| | | | | | | This fixes a regression that made clang -flto -Wl,--plugin-opt=-mattr=+aes not pass the "+aes" option to the LTOCodeGenerator attributes. llvm-svn: 211804
* Small clanups:Rafael Espindola2014-06-201-36/+22
| | | | | | | Use static instead of anonymous namespace. Delete write only variables. llvm-svn: 211335
* The gold plugin doesn't need disassemblers.Rafael Espindola2014-06-191-1/+0
| | | | | | | | Back in r128440 tools/LTO started exporting the disassembler interface. It was never clear why, but whatever the reason I am pretty sure it doesn't hold for tools/gold. llvm-svn: 211325
* Set gold plugin options in a sane order.Rafael Espindola2014-06-191-12/+12
| | | | | | | | | | | This fixes the processing of --plugin-opt=-jump-table-type=arity. Nice properties: * We call InitTargetOptionsFromCodeGenFlags once. * We call parseCodeGenDebugOptions once. * It works :-) llvm-svn: 211322
* Simplify. No functionality change.Rafael Espindola2014-06-191-2/+1
| | | | | | Thanks to Alp Toker for noticing it. llvm-svn: 211320
* Reduce indentation. No functionality change.Rafael Espindola2014-06-191-18/+18
| | | | llvm-svn: 211318
* Use lib/LTO directly in the gold plugin.Rafael Espindola2014-06-191-32/+61
| | | | | | | | | | | | | | | | | | | | The tools/lto API is not the best choice for implementing a gold plugin. Among other issues: * It is an stable ABI. Old errors stay and we have to be really careful before adding new features. * It has to support two fairly different linkers: gold and ld64. * We end up with a plugin that depends on a shared lib, something quiet unusual in LLVM land. * It hides LLVM. For some features in the gold plugin it would be really nice to be able to just get a Module or a GlobalValue. This change is intended to be a very direct translation from the C API. It will just enable other fixes and cleanups. Tested with a LTO bootstrap on linux. llvm-svn: 211315
* Remove an incorrect fixme.Rafael Espindola2014-06-191-2/+0
| | | | | | | dynamic-no-pic is just another output type. If gnu ld gets support for MachO, it should also add something like LDPO_DYN_NO_PIC to the plugin interface. llvm-svn: 211305
* Remove 'using std::error_code' from tools.Rafael Espindola2014-06-131-3/+2
| | | | llvm-svn: 210876
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-0/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* Remove system_error.h.Rafael Espindola2014-06-121-1/+1
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. llvm-svn: 210803
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-2/+1
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* Improve the declaration when LDPO_PIE is not available.Sylvestre Ledru2014-02-111-7/+6
| | | | | | Thanks to İsmail Dönmez for the better declaration. llvm-svn: 201163
* If LDPO_PIE is not defined (before binutils 2.23 version), Sylvestre Ledru2014-02-111-0/+7
| | | | | | | use the hardcoded declaration 3 See r201110 for the initial change llvm-svn: 201161
* Fix an old FIXME. LDPO_PIE is available since 2.23, realeased 2012-10-22.Rafael Espindola2014-02-101-2/+1
| | | | llvm-svn: 201110
* Re-sort #include lines again, prior to moving headers around.Chandler Carruth2014-01-131-2/+2
| | | | llvm-svn: 199080
* gold-plugin.cpp: Use form of <plugin-api.h>, since it is external header.NAKAMURA Takumi2013-12-251-1/+1
| | | | llvm-svn: 197997
* Use LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN instead of the "dso list".Rafael Espindola2013-10-311-6/+15
| | | | | | | | | | | | | | | | | | | | | | There are two ways one could implement hiding of linkonce_odr symbols in LTO: * LLVM tells the linker which symbols can be hidden if not used from native files. * The linker tells LLVM which symbols are not used from other object files, but will be put in the dso symbol table if present. GOLD's API is the second option. It was implemented almost 1:1 in llvm by passing the list down to internalize. LLVM already had partial support for the first option. It is also very similar to how ld64 handles hiding these symbols when *not* doing LTO. This patch then * removes the APIs for the DSO list. * marks LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN all linkonce_odr unnamed_addr global values and other linkonce_odr whose address is not used. * makes the gold plugin responsible for handling the API mismatch. llvm-svn: 193800
* Check for errors when calling lto_codegen_add_module in the gold plugin.Rafael Espindola2013-10-181-2/+7
| | | | | | Thanks to Milan Lenčo for noticing it. llvm-svn: 192996
* [pr17595] Fix a use after free.Rafael Espindola2013-10-161-6/+11
| | | | | | | Destroying the codegen also frees the path of the created object. Copy the path to a std::string. llvm-svn: 192787
* Optimize linkonce_odr unnamed_addr functions during LTO.Rafael Espindola2013-10-031-1/+6
| | | | | | | | | | | Generalize the API so we can distinguish symbols that are needed just for a DSO symbol table from those that are used from some native .o. The symbols that are only wanted for the dso symbol table can be dropped if llvm can prove every other dso has a copy (linkonce_odr) and the address is not important (unnamed_addr). llvm-svn: 191922
* Dispose the codegen even when just writing the bitcode file.Rafael Espindola2013-10-031-1/+3
| | | | | | | This makes it possible to add timers to the code generator and still use them with -plugin-opt=emit-llvm. llvm-svn: 191866
* Revert r188188 and r188200.Shuxin Yang2013-08-121-24/+8
| | | | | | | | In order to appease people (in Apple) who accuse me for committing "huge change" (?) without proper review. Thank Eric for fixing a compile-warning. llvm-svn: 188204
* Misc enhancements to LTO:Shuxin Yang2013-08-121-8/+24
| | | | | | | | | | | | | | | | | | | | | 1. Add some helper classes for partitions. They are designed in a way such that the top-level LTO driver will not see much difference with or without partitioning. 2. Introduce work-dir. Now all intermediate files generated during LTO phases will be saved under work-dir. User can specify the workdir via -lto-workdir=/path/to/dir. By default the work-dir will be erased before linker exit. To keep the workdir, do -lto-keep, or -lto-keep=1. TODO: Erase the workdir, if the linker exit prematurely. We are currently not able to remove directory on signal. The support routines simply ignore directory. 3. Add one new API lto_codegen_get_files_need_remove(). Linker and LTO plugin will communicate via this API about which files (including directories) need to removed before linker exit. llvm-svn: 188188
* Split getOpenFile into getOpenFile and getOpenFileSlice.Rafael Espindola2013-07-231-3/+2
| | | | | | | | | | | | | | | | The main observation is that we never need both the filesize and the map size. When mapping a slice of a file, it doesn't make sense to request a null terminator and that would be the only case where the filesize would be used. There are other cleanups that should be done in this area: * A client should not have to pass the size (even an explicit -1) to say if it wants a null terminator or not, so we should probably swap the argument order. * The default should be to not require a null terminator. Very few clients require this, but many end up asking for it just because it is the default. llvm-svn: 186984
* Fix use of the getOpenFile api.Rafael Espindola2013-07-231-2/+2
| | | | | | | | | | | | | | | | The gold plugin was passing the desired map size as the file size. This was working for two reasons: * Recent version of gold provide the get_view callback, so this code was not used. * In older versions, getOpenFile was called, but the file size is never used if we don't require null terminated buffers and map size defaults to the file size. Thanks to Eli Bendersky for noticing this. I will try to make this api a bit less error prone. llvm-svn: 186978
* Fix the build with gcc 4.7 and -std=c++11.Rafael Espindola2013-06-171-1/+1
| | | | | | | | | | | The error message was: /home/espindola/llvm/llvm/tools/gold/gold-plugin.cpp: In function ‘ld_plugin_status cleanup_hook()’: /home/espindola/llvm/llvm/tools/gold/gold-plugin.cpp:461:30: error: cannot pass objects of non-trivially-copyable type ‘std::string {aka class std::basic_string<char>}’ through ‘...’ I will check if this was a clang or gcc issue. llvm-svn: 184138
* Don't use PathV1.h in tools/gold/gold-plugin.cpp.Rafael Espindola2013-06-171-8/+8
| | | | llvm-svn: 184099
* Avoid using PathV1.h in Program.h.Rafael Espindola2013-06-131-0/+1
| | | | llvm-svn: 183940
* Sort the #include lines for tools/...Chandler Carruth2012-12-041-6/+3
| | | | | | | | Again, tools are trickier to pick the main module header for than library source files. I've started to follow the pattern of using LLVMContext.h when it is included as a stub for program source files. llvm-svn: 169252
* libLTO has a bug in that it will keep every symbol if none is needed. We usedRafael Espindola2012-10-261-10/+0
| | | | | | | | | | to hack around this in the gold plugin by deleting a module if no symbol was needed. Unfortunately, the hack is wrong in the case of o module having no visible symbols but still having side effects via static constructors. The bug will have to be fixed in libLTO itself. llvm-svn: 166745
* Use LTO_CODEGEN_PIC_MODEL_DYNAMIC for PIE. This requirest a git version ofRafael Espindola2012-06-131-0/+2
| | | | | | | | gold to work. Since the enum value LDPO_PIE has just been added to plugin-api.h, use a numeric constant for now so that we don't require an unreleased version of gold to build. llvm-svn: 158402
* drop unneeded config.h includesDylan Noblesmith2011-12-221-1/+1
| | | | llvm-svn: 147197
* use 64-bit types instead of off_t/size_t to avoid the issue whenIvan Krasin2011-09-151-1/+1
| | | | | | | | gold plugin is built with Large File Support (sizeof(off_t) == 64 on i686) and the rest of LLVM is built w/o Large File Support (sizeof(off_t) == 32 on i686) which corrupts the stack. llvm-svn: 139873
* gold plugin: don't report error on non-bitcode (e.g. ELF) files.Ivan Krasin2011-09-121-9/+25
| | | | llvm-svn: 139544
* gold plugin: report errors occured in lto_module_create_from_*Ivan Krasin2011-09-091-1/+6
| | | | llvm-svn: 139340
* Don't try to dereference syms[0] on an empty vector. Reported by Todd JacksonNick Lewycky2011-07-261-0/+2
| | | | | | and Jeffrey Bosboom! llvm-svn: 136066
* Remove an unused variable.Duncan Sands2011-05-041-1/+0
| | | | llvm-svn: 130860
* If present, use gold's support for getting a file view. This prevents havingRafael Espindola2011-04-071-1/+12
| | | | | | to map the file both in the linker and in the plugin. llvm-svn: 129109
* Add a lto_codegen_compile_to_file to avoid producing a file, reading it toRafael Espindola2011-03-221-30/+2
| | | | | | memory and writing it back to disk. llvm-svn: 128108
* Add support in the LTO library for loading an object from the middleRafael Espindola2011-03-171-37/+4
| | | | | | of an file. llvm-svn: 127781
* Gold now rescans archives as needed, so the pass-through options are notRafael Espindola2011-02-271-22/+0
| | | | | | necessary anymore. llvm-svn: 126580
* bfd was fixed, remove the work around.Rafael Espindola2011-02-271-12/+1
| | | | llvm-svn: 126579
* LTO uses MC now.Rafael Espindola2011-02-261-24/+0
| | | | llvm-svn: 126546
* Dispose modules early and only create codegen when the plugin is beingRafael Espindola2011-02-201-5/+19
| | | | | | used by the linker and not by nm or ar. llvm-svn: 126089
OpenPOWER on IntegriCloud