1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

325 Commits

Author SHA1 Message Date
Rafael Espindola
ce9d67c91b Be less conservative about when we build the gold plugin.
It is only build if LLVM_BINUTILS_INCDIR is explicitly given, so there is
no point in having extra restrictions.

llvm-svn: 223481
2014-12-05 17:25:52 +00:00
Rafael Espindola
4252588d37 gold plugin: call llvm_shutdown so that -stats works.
llvm-svn: 222787
2014-11-25 20:52:49 +00:00
Rafael Espindola
9584ebd5dc Add a disable-output option to the gold plugin.
This corresponds to the opt option and is handy for profiling.

llvm-svn: 222687
2014-11-24 21:18:14 +00:00
Duncan P. N. Exon Smith
a92d042317 gold-plugin: Fix typo in error message
Spotted while reading code.

llvm-svn: 222395
2014-11-19 22:39:21 +00:00
Rafael Espindola
5d4d6baa1f Fix the build of the gold plugin.
I did the previous patch on OS X and didn't noticed the issue.

llvm-svn: 221070
2014-11-01 23:49:44 +00:00
Rafael Espindola
20114e4c02 Remove redundant calls to isMaterializable.
This removes calls to isMaterializable in the following cases:

* It was redundant with a call to isDeclaration now that isDeclaration returns
  the correct answer for materializable functions.
* It was followed by a call to Materialize. Just call Materialize and check EC.

llvm-svn: 221050
2014-11-01 16:46:18 +00:00
Rafael Espindola
4c2829a415 Enable the slp vectorizer in the gold plugin.
llvm-svn: 220887
2014-10-30 00:38:54 +00:00
Rafael Espindola
dd4a731a5e Enable the loop vectorizer in the gold plugin.
llvm-svn: 220886
2014-10-30 00:11:24 +00:00
Rafael Espindola
3652fa83cf Replace also-emit-llvm with save-temps.
The also-emit-llvm option only supported getting the IR before optimizations.
This patch replaces it with a more generic save-temps option that saves the IR
both before and after optimizations.

llvm-svn: 220885
2014-10-29 23:54:45 +00:00
Rafael Espindola
55ba2fb803 Remove unused variable.
llvm-svn: 220610
2014-10-25 04:07:53 +00:00
Rafael Espindola
67b4b608c2 Update the error handling of lib/Linker.
Instead of passing a std::string&, use the new diagnostic infrastructure.

llvm-svn: 220608
2014-10-25 04:06:10 +00:00
Rafael Espindola
ee06e286d8 Modernize the error handling of the Materialize function.
llvm-svn: 220600
2014-10-24 22:50:48 +00:00
Rafael Espindola
e4018b9baa Don't ever call materializeAllPermanently during LTO.
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
2014-10-24 18:13:04 +00:00
Rafael Espindola
1cc1b9191d Fix a gcc warning.
Thanks to Filipe Cabecinhas for the report.

llvm-svn: 220361
2014-10-22 02:23:31 +00:00
Rafael Espindola
9b8aaa2711 Fix gcc warning in gold-plugin.cpp.
Patch by Markus Trippelsdorf!

llvm-svn: 219459
2014-10-10 00:48:13 +00:00
Rafael Espindola
e799beebfd gold plugin: Handle gold selecting a linkonce GV when a weak is present.
The plugin API doesn't have the notion of linkonce, only weak. It is up to the
plugin to figure out if a symbol used only for the symbol table can be dropped.
In particular, it has to avoid dropping a linkonce_odr selected by gold if there
is also a weak_odr.

llvm-svn: 219188
2014-10-07 04:06:13 +00:00
Rafael Espindola
c75d5a7ac9 gold plugin: create internal replacement with original linkage first.
The call to copyAttributesFrom will copy the visibility, which might assert
if it were to produce something invalid like "internal hidden". We avoid it
by first creating the replacement with the original linkage and then setting
it to internal affter the call to copyAttributesFrom.

llvm-svn: 219184
2014-10-07 03:19:55 +00:00
Rafael Espindola
cc59b6926d gold plugin: Remap function arguments when creating a replacement function.
When creating an internal function replacement for use in an alias we were
not remapping the argument uses in the instructions to point to the new
arguments.

llvm-svn: 219177
2014-10-07 00:47:38 +00:00
Peter Collingbourne
3d7ffbad08 LTO: introduce object file-based on-disk module format.
This format is simply a regular object file with the bitcode stored in a
section named ".llvmbc", plus any number of other (non-allocated) sections.

One immediate use case for this is to accommodate compilation processes
which expect the object file to contain metadata in non-allocated sections,
such as the ".go_export" section used by some Go compilers [1], although I
imagine that in the future we could consider compiling parts of the module
(such as large non-inlinable functions) directly into the object file to
improve LTO efficiency.

[1] http://golang.org/doc/install/gccgo#Imports

Differential Revision: http://reviews.llvm.org/D4371

llvm-svn: 218078
2014-09-18 21:28:49 +00:00
Rafael Espindola
10b142b791 Internalize common symbols when we can.
This fixes pr20974.

llvm-svn: 217981
2014-09-17 20:41:13 +00:00
Rafael Espindola
4753b87f60 Add doInitialization/doFinalization to DataLayoutPass.
With this a DataLayoutPass can be reused for multiple modules.

Once we have doInitialization/doFinalization, it doesn't seem necessary to pass
a Module to the constructor.

Overall this change seems in line with the idea of making DataLayout a required
part of Module. With it the only way of having a DataLayout used is to add it
to the Module.

llvm-svn: 217548
2014-09-10 21:27:43 +00:00
Rafael Espindola
f22493d161 Remember to eraseFromParent after replaceAllUsesWith.
llvm-svn: 217536
2014-09-10 19:39:41 +00:00
Rafael Espindola
5d2ea83b96 Handle common linkage correctly in the gold plugin.
This is the plugin version of pr20882.

This handles the case of every common symbol being in the IR. We will need some
support from gold to handle the case where some symbols are in ELF and some in
the IR.

llvm-svn: 217458
2014-09-09 20:08:22 +00:00
David Blaikie
9ec4b63537 unique_ptrify IRObjectFile::createIRObjectFile
I took a guess at the changes to the gold plugin, because that doesn't
seem to build by default for me. Not sure what dependencies I might be
missing for that.

llvm-svn: 217056
2014-09-03 17:59:23 +00:00
Rafael Espindola
cbfc7723a8 Pass a && to getLazyBitcodeModule.
This forces callers to use std::move when calling it. It is somewhat odd to have
code with std::move that doesn't always move, but it is also odd to have code
without std::move that sometimes moves.

llvm-svn: 217049
2014-09-03 17:31:46 +00:00
Rafael Espindola
f3e2676960 Don't create a MemoryBuffer just to get the MemoryBufferRef. NFC.
llvm-svn: 216608
2014-08-27 20:25:55 +00:00
David Blaikie
dc5788792a Convert a few more cases of direct intialization of unique_ptrs from MemoryBuffer::getMemBuffer to move initialization now that it returns by unique_ptr instead of raw pointer.
Cleanup/improvements following r216583.

llvm-svn: 216605
2014-08-27 20:14:18 +00:00
Rafael Espindola
edb6051959 Return a std::unique_ptr when creating a new MemoryBuffer.
llvm-svn: 216583
2014-08-27 20:03:13 +00:00
Rafael Espindola
a2d7cc97be Pass a std::unique_ptr<MemoryBuffer>& to getLazyBitcodeModule.
By taking a reference we can do the ownership transfer in one place instead of
expecting every caller to do it.

llvm-svn: 216492
2014-08-26 22:00:09 +00:00
Rafael Espindola
1d5713d9bf Modernize raw_fd_ostream's constructor a bit.
Take a StringRef instead of a "const char *".
Take a "std::error_code &" instead of a "std::string &" for error.

A create static method would be even better, but this patch is already a bit too
big.

llvm-svn: 216393
2014-08-25 18:16:47 +00:00
Rafael Espindola
bdb4d2f2db Add support for comdats to the gold plugin.
There are two parts to this. First, the plugin needs to tell gold the comdat by
setting comdat_key.

What gets things a bit more complicated is that gold only seems
symbols. In particular, if A is an alias to B, it only sees the symbols
A and B. It can then ask us to keep symbol A but drop symbol B. What
we have to do instead is to create an internal version of B and make A
an alias to that.

At some point some of this logic should be moved to lib/Linker so that
we don't map a Constant to an internal version just to have lib/Linker
map that again to the destination module.

The reason for implementing this in tools/gold for now is simplicity.
With it in place it should be possible to update clang to use comdats
for constructors and destructors on ELF without breaking the LTO
bootstrap. Once that is done I intend to come back and improve the
interface lib/Linker exposes.

llvm-svn: 216302
2014-08-22 23:26:10 +00:00
Rafael Espindola
77b37756aa Rewrite the gold plugin to fix pr19901.
There is a fundamental difference between how the gold API and lib/LTO view
the LTO process.

The gold API talks about a particular symbol in a particular file. The lib/LTO
API talks about a symbol in the merged module.

The merged module is then defined in terms of the IR semantics. In particular,
a linkonce_odr GV is only copied if it is used, since it is valid to drop
unused linkonce_odr GVs.

In the testcase in pr19901 both properties collide. What happens is that gold
asks us to keep a particular linkonce_odr symbol, but the IR linker doesn't
copy it to the merged module and we never have a chance to ask lib/LTO to keep
it.

This patch fixes it by having a more direct implementation of the gold API. If
it asks us to keep a symbol, we change the linkage so it is not linkonce. If it
says we can drop a symbol, we do so. All of this before we even send the module
to lib/Linker.

Since now we don't have to produce LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN,
during symbol resolution we can use a temporary LLVMContext and do lazy
module loading. This allows us to keep the minimum possible amount of
allocated memory around. This should also allow as much parallelism as
we want, since there is no shared context.

llvm-svn: 216215
2014-08-21 20:28:55 +00:00
Rafael Espindola
bbd64cd25c Fix using -plugin-opt=apiflie when also using -plugin-opt=emit-llvm.
llvm-svn: 215378
2014-08-11 19:06:54 +00:00
Rafael Espindola
5b7cf03381 Remove unused argument.
Thanks to Justin Bogner for noticing it.

llvm-svn: 214426
2014-07-31 19:32:04 +00:00
Rafael Espindola
d95a431fd9 Use range loops.
llvm-svn: 214280
2014-07-30 01:52:40 +00:00
Rafael Espindola
9f7e19243c Convert a few more function pointer calls to just "f()".
llvm-svn: 214276
2014-07-30 01:36:32 +00:00
Rafael Espindola
d5c0acb861 Don't duplicate the function name in a comment.
llvm-svn: 214272
2014-07-30 01:23:45 +00:00
Rafael Espindola
aa8e1b8d73 Use function pointers with just f(1,2) instead of (*f)(1,2).
llvm-svn: 214265
2014-07-30 00:38:58 +00:00
Rafael Espindola
52959c50e9 Use nullptr instead of NULL.
llvm-svn: 214229
2014-07-29 21:46:05 +00:00
Rafael Espindola
debf00a333 Remove unused includes.
llvm-svn: 214226
2014-07-29 21:38:05 +00:00
Rafael Espindola
50859a1427 Delete dead code.
The gold plugin doesn't call lseek or read directly any more.

llvm-svn: 214221
2014-07-29 21:09:43 +00:00
Rafael Espindola
959d066783 gold plugin: Fix handling of corrupted bitcode files.
We should still claim them and tell gold about the error.

llvm-svn: 214214
2014-07-29 20:46:19 +00:00
Rafael Espindola
ace129d81b Small gold plugin simplifications.
* Use a range loop.
* Store the extra options as "const char *".

llvm-svn: 214199
2014-07-29 19:17:44 +00:00
Rafael Espindola
aecbc5b288 Use raw_fd_ostream instead of std::ofstream.
llvm-svn: 212483
2014-07-07 20:34:51 +00:00
Rafael Espindola
858b9e1423 Update the MemoryBuffer API to use ErrorOr.
llvm-svn: 212405
2014-07-06 17:43:13 +00:00
Rafael Espindola
5b4502ed15 Declare variable on first use.
llvm-svn: 212403
2014-07-06 14:31:22 +00:00
Peter Collingbourne
899429ccd4 gold plugin: move target initialization to the top of the onload function.
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
2014-07-03 23:28:03 +00:00
Peter Collingbourne
83a67bf953 LTO: rename the various makeLTOModule overloads.
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
2014-07-03 23:28:00 +00:00
Tom Roeder
cbe6cfcc8e Fix the new LTOCodeGenerator setup in gold to parse options before using MAttrs.
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
2014-06-26 20:43:27 +00:00
Alexey Volkov
ba8b63c17a Fix unresolved symbols when loading gold plugin
Differential Revision: http://reviews.llvm.org/D4275

llvm-svn: 211675
2014-06-25 08:04:58 +00:00
Rafael Espindola
0eed03b4fe Small clanups:
Use static instead of anonymous namespace.
Delete write only variables.

llvm-svn: 211335
2014-06-20 01:37:35 +00:00
Rafael Espindola
19aa71b28a The gold plugin doesn't need disassemblers.
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
2014-06-19 23:06:53 +00:00
Rafael Espindola
e3ebefe7b1 Set gold plugin options in a sane order.
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
2014-06-19 22:54:47 +00:00
Rafael Espindola
efbf6a1361 Simplify. No functionality change.
Thanks to Alp Toker for noticing it.

llvm-svn: 211320
2014-06-19 22:33:23 +00:00
Rafael Espindola
402a76c96d Reduce indentation. No functionality change.
llvm-svn: 211318
2014-06-19 22:20:07 +00:00
Rafael Espindola
b6a8a137f8 Use lib/LTO directly in the gold plugin.
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
2014-06-19 21:14:13 +00:00
Rafael Espindola
fdda9ecccd Remove an incorrect fixme.
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
2014-06-19 19:45:25 +00:00
Rafael Espindola
5c15b3d369 Remove 'using std::error_code' from tools.
llvm-svn: 210876
2014-06-13 03:07:50 +00:00
Rafael Espindola
e0e308ff6d Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

llvm-svn: 210835
2014-06-12 21:46:39 +00:00
Rafael Espindola
38dc624425 Remove system_error.h.
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
2014-06-12 17:38:55 +00:00
Ahmed Charles
52ce0c101e Replace OwningPtr<T> with std::unique_ptr<T>.
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
2014-03-06 05:51:42 +00:00
Rafael Espindola
31fb44e657 Don't mix the plain and keyword signatures of target_link_libraries.
llvm-svn: 202299
2014-02-26 20:39:28 +00:00
Sylvestre Ledru
ef254433f4 Improve the declaration when LDPO_PIE is not available.
Thanks to İsmail Dönmez for the better declaration.

llvm-svn: 201163
2014-02-11 17:30:18 +00:00
Sylvestre Ledru
862cdddf18 If LDPO_PIE is not defined (before binutils 2.23 version),
use the hardcoded declaration 3
See r201110 for the initial change

llvm-svn: 201161
2014-02-11 17:11:32 +00:00
Rafael Espindola
b1c77f900f Fix an old FIXME. LDPO_PIE is available since 2.23, realeased 2012-10-22.
llvm-svn: 201110
2014-02-10 20:38:38 +00:00
Chandler Carruth
03b6c941a3 Re-sort #include lines again, prior to moving headers around.
llvm-svn: 199080
2014-01-13 08:04:33 +00:00
Tom Roeder
1954800ba6 Space formatting fix for r198966.
llvm-svn: 198971
2014-01-10 23:17:39 +00:00
Tom Roeder
6ed65beaae Fixing build break: should be in the if statement, not outside.
llvm-svn: 198966
2014-01-10 22:55:25 +00:00
Tom Roeder
9b68196561 Restore the library dependency of LLVMgold on LTO; this was removed recently but
is needed for LLVMgold to load in ld.

llvm-svn: 198965
2014-01-10 22:48:35 +00:00
Nico Weber
6711c182c4 EXPORTED_SYMBOL_FILE support for cmake
The cmake build didn't support EXPORTED_SYMBOL_FILE. Instead, it had a
Windows-only implementation in tools/lto/CMakeLists.txt, a linux-only
implementation in tools/gold/CMakeLists.txt, and a darwin-only implementation
in tools/clang/tools/libclang/CMakeLists.txt.

This attempts to consolidate these one-offs into a single place. Clients can now
just set LLVM_EXPORTED_SYMBOL_FILE and things (hopefully) Just Work, like in
the make build.

llvm-svn: 198136
2013-12-28 23:31:44 +00:00
NAKAMURA Takumi
c51a9bddf6 gold-plugin.cpp: Use form of <plugin-api.h>, since it is external header.
llvm-svn: 197997
2013-12-25 02:24:38 +00:00
Alp Toker
402d68071c Cut the gold plugin README down to size
This file hasn't been updated in years. Remove old information and point to
the current documentation at GoldPlugin.rst.

llvm-svn: 196100
2013-12-02 14:17:47 +00:00
Rafael Espindola
24353f2de2 Use LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN instead of the "dso list".
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
2013-10-31 20:51:58 +00:00
Rafael Espindola
991f723e21 Check for errors when calling lto_codegen_add_module in the gold plugin.
Thanks to Milan Lenčo for noticing it.

llvm-svn: 192996
2013-10-18 19:32:06 +00:00
Rafael Espindola
ec9d21071a [pr17595] Fix a use after free.
Destroying the codegen also frees the path of the created object. Copy the
path to a std::string.

llvm-svn: 192787
2013-10-16 12:47:04 +00:00
Rafael Espindola
a88c415234 Optimize linkonce_odr unnamed_addr functions during LTO.
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
2013-10-03 18:29:09 +00:00
Rafael Espindola
22fa62d2f8 Dispose the codegen even when just writing the bitcode file.
This makes it possible to add timers to the code generator and still use them
with -plugin-opt=emit-llvm.

llvm-svn: 191866
2013-10-03 00:07:30 +00:00
Shuxin Yang
b3af4b7f36 Revert r188188 and r188200.
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
2013-08-12 21:07:31 +00:00
Shuxin Yang
4b4ff9ec1f Misc enhancements to LTO:
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
2013-08-12 18:29:43 +00:00
Rafael Espindola
f3a9f67eee Split getOpenFile into getOpenFile and getOpenFileSlice.
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
2013-07-23 20:25:01 +00:00
Rafael Espindola
8f45894865 Fix use of the getOpenFile api.
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
2013-07-23 18:44:31 +00:00
Rafael Espindola
6a0b079beb Fix the build with gcc 4.7 and -std=c++11.
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
2013-06-17 22:24:06 +00:00
Rafael Espindola
90268d76aa Don't use PathV1.h in tools/gold/gold-plugin.cpp.
llvm-svn: 184099
2013-06-17 18:38:18 +00:00
Rafael Espindola
ef0d0d8b0b Avoid using PathV1.h in Program.h.
llvm-svn: 183940
2013-06-13 20:25:38 +00:00
Chandler Carruth
800daa7d3d Sort the #include lines for tools/...
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
2012-12-04 10:44:52 +00:00
Rafael Espindola
1523a24050 libLTO has a bug in that it will keep every symbol if none is needed. We used
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
2012-10-26 00:29:57 +00:00
Rafael Espindola
41573a702b Pass -lLTO after gold-plugin.o so that it gets used in systems that default to
--as-needed.
Patch by Felix Geyer. Fixes pr13262.

llvm-svn: 162652
2012-08-27 03:03:07 +00:00
Rafael Espindola
a0d94f4f75 Use LTO_CODEGEN_PIC_MODEL_DYNAMIC for PIE. This requirest a git version of
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
2012-06-13 13:30:24 +00:00
Dylan Noblesmith
40dea4f20c drop unneeded config.h includes
llvm-svn: 147197
2011-12-22 23:04:07 +00:00
Rafael Espindola
17a991f91c Point to libLTO with -L/PATH/ -lLTO so that it is found in the install
directory.
Patch by Markus Trippelsdorf.

llvm-svn: 145095
2011-11-23 03:07:25 +00:00
Peter Collingbourne
470083dc27 Use absolute path to exportsfile in gold plugin CMake build.
(Ninja generator requirement.)

llvm-svn: 143783
2011-11-05 04:17:20 +00:00
Daniel Dunbar
81780d9982 build: Tidy up a bunch of tool Makefiles, and simplify where possible using the
new all-targets pseudo-component.

llvm-svn: 142401
2011-10-18 19:27:24 +00:00
Ivan Krasin
de2d3cf093 use 64-bit types instead of off_t/size_t to avoid the issue when
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
2011-09-15 23:13:00 +00:00
Ivan Krasin
6b8225fcda gold plugin: don't report error on non-bitcode (e.g. ELF) files.
llvm-svn: 139544
2011-09-12 21:47:50 +00:00
Ivan Krasin
19d51af328 gold plugin: report errors occured in lto_module_create_from_*
llvm-svn: 139340
2011-09-09 00:14:04 +00:00
Nick Lewycky
f3995084c9 Don't try to dereference syms[0] on an empty vector. Reported by Todd Jackson
and Jeffrey Bosboom!

llvm-svn: 136066
2011-07-26 08:40:36 +00:00
Nick Lewycky
d35075f814 Also remove -lLTO which should have been in r132349. I failed to apply this
from David Meyer's patch!

llvm-svn: 132352
2011-05-31 20:00:45 +00:00
Nick Lewycky
2e4a814868 Make the gold plugin build on Cygwin as well as Linux. Patch by David Meyer!
llvm-svn: 132349
2011-05-31 19:53:26 +00:00
Oscar Fuentes
d323e73950 CMake builds gold by default since revision 127466. This is
inconsistent with autoconf, which by default set BINUTILS_INCDIR to
empty and exclude gold from target list.

Based on a patch by Haitao Li!

llvm-svn: 131229
2011-05-12 11:26:21 +00:00
Duncan Sands
9a37d60dff Remove an unused variable.
llvm-svn: 130860
2011-05-04 19:13:01 +00:00
Rafael Espindola
61e0c74936 If present, use gold's support for getting a file view. This prevents having
to map the file both in the linker and in the plugin.

llvm-svn: 129109
2011-04-07 21:11:00 +00:00
Rafael Espindola
1592f3ae24 Add a lto_codegen_compile_to_file to avoid producing a file, reading it to
memory and writing it back to disk.

llvm-svn: 128108
2011-03-22 20:57:13 +00:00
Rafael Espindola
8dab9a762b Add support in the LTO library for loading an object from the middle
of an file.

llvm-svn: 127781
2011-03-17 00:36:11 +00:00
Oscar Fuentes
548931d606 Force re-linking of LLVMgold.so when its exports file changes.
llvm-svn: 127473
2011-03-11 18:27:13 +00:00
Oscar Fuentes
d83646bbfd Fix processing of gold.exports.
llvm-svn: 127471
2011-03-11 18:07:46 +00:00
Oscar Fuentes
57a2625738 Add LTO and gold plugin to the CMake build. Linux-only, support for
other systems pending.

PR9456.

llvm-svn: 127466
2011-03-11 15:44:24 +00:00
Rafael Espindola
53fdf0bfc1 Gold now rescans archives as needed, so the pass-through options are not
necessary anymore.

llvm-svn: 126580
2011-02-27 20:30:22 +00:00
Rafael Espindola
744cde8b39 bfd was fixed, remove the work around.
llvm-svn: 126579
2011-02-27 20:15:37 +00:00
Rafael Espindola
13bfff7d40 LTO uses MC now.
llvm-svn: 126546
2011-02-26 16:44:13 +00:00
Rafael Espindola
83ad96cc73 Dispose modules early and only create codegen when the plugin is being
used by the linker and not by nm or ar.

llvm-svn: 126089
2011-02-20 18:28:29 +00:00
Rafael Espindola
f2fd1bf3d8 Add modules to codegen as soon as possible. This reduces the link time
of libxul from 12m31.084s to 7m1.359s.

llvm-svn: 126052
2011-02-19 21:49:57 +00:00
Rafael Espindola
3c40b1fab0 Add a debug obj-path option to make it easy to keep the .o produce by LTO.
llvm-svn: 125663
2011-02-16 11:19:44 +00:00
Rafael Espindola
3c32af5834 Switch llvm to using comdats. For now always use groups with a single
section.

llvm-svn: 125526
2011-02-14 22:23:49 +00:00
Rafael Espindola
43f9672afa Don't open the file again in the gold plugin. To be able to do this, update
MemoryBuffer::getOpenFile to not close the file descriptor.

llvm-svn: 125128
2011-02-08 22:40:47 +00:00
Michael J. Spencer
2bf08ad59d gold: MinGW fix.
llvm-svn: 123886
2011-01-20 05:43:16 +00:00
Charles Davis
e7f14dfdb8 Now to chant the magical incantation that will exorcise the System library
from LLVM forever:

grep -lR "llvm/System" * | grep -v .svn | xargs sed -ie 's#llvm/System#llvm/Support#g'

llvm-svn: 120314
2010-11-29 19:44:50 +00:00
Michael J. Spencer
4a63404543 I swear I did a make clean and make before committing all this...
llvm-svn: 120304
2010-11-29 18:47:54 +00:00
Dan Gohman
6645ce3f75 Move tool_output_file into its own file.
llvm-svn: 115973
2010-10-07 20:32:40 +00:00
NAKAMURA Takumi
7857655635 Don't build redundant libLLVMgold.a.
Building archive would be executed due to definition of BUILD_ARCHIVE,
even if BUILD_ARCHIVE = "0".

llvm-svn: 113578
2010-09-10 06:26:57 +00:00
Nick Lewycky
7d3f15bab3 Fix compile errors.
llvm-svn: 112808
2010-09-02 05:44:31 +00:00
Dan Gohman
d8be4c4aca Convert tools to use tool_output_file, and introduce error
checking to places which previously lacked it.

llvm-svn: 111651
2010-08-20 16:59:15 +00:00
Rafael Espindola
f345661269 Make it possible to set the cpu used for codegen.
llvm-svn: 110759
2010-08-11 00:15:13 +00:00
Rafael Espindola
c61143ae75 Make it possible to set the flags passed to the assembler.
Nick, please review.

llvm-svn: 110705
2010-08-10 18:55:09 +00:00
Rafael Espindola
acfdd67ec8 Fix silly bug.
llvm-svn: 110684
2010-08-10 16:32:15 +00:00
Rafael Espindola
fd90a58cd3 Make it possible to set the target triple and expose that with an option in the
gold plugin.

llvm-svn: 110604
2010-08-09 21:09:46 +00:00
Rafael Espindola
c3b766cc93 s/libLLVMgold/LLVMgold/g
llvm-svn: 110552
2010-08-08 21:14:26 +00:00
Duncan Sands
d0286618b5 Remove variables that are written by not read.
llvm-svn: 107126
2010-06-29 11:07:47 +00:00
Rafael Espindola
ea22615ccd Add an extra-library-path option to the plugin. This is used to support
having a library both as bitcode and native code. We want to use the
bitcode first, but if codegen produces new undefined references we have to use
the native code to satisfy those references.

Gold has no notion of bitcode and native search directories, so instead it has
an API where the plugin can instruct it to look for the libraries it is passing
to it. This patch uses that API.

llvm-svn: 106674
2010-06-23 20:20:59 +00:00
Rafael Espindola
705c2bd4c3 add_input_file and add_input_library now take const arguments, remove the
const_cast.

llvm-svn: 106410
2010-06-21 02:23:12 +00:00
Rafael Espindola
d7bfa3a0f7 Add a pass-through option to the plugin. The use case for this option is to
ask the linker to take another look into some library or object. The case when
one might want to do this is when codegen introduces a new undefined reference.
The canonical example is libgcc.

llvm-svn: 106303
2010-06-18 19:18:58 +00:00
Rafael Espindola
23f533848f Don't produce output only if *all* files are unused.
llvm-svn: 105962
2010-06-14 21:20:52 +00:00
Nick Lewycky
ff1e3db00e Plug a leak in the non-error case by removing one level of indirection.
llvm-svn: 105556
2010-06-07 21:42:19 +00:00
Rafael Espindola
b93be14fa0 Misc cleanups to the gold plugin.
llvm-svn: 105534
2010-06-07 16:45:22 +00:00
Rafael Espindola
ee11d1e6a5 Add a emit-llvm option to the plugin and make the path argument to also-emit-llvm optional.
llvm-svn: 105414
2010-06-03 21:11:20 +00:00
Nick Lewycky
14c5598c42 Perfer !string.empty() over string != "".
llvm-svn: 105397
2010-06-03 17:13:23 +00:00
Nick Lewycky
04d3d4e46f Whitespace cleanup.
llvm-svn: 105395
2010-06-03 17:10:17 +00:00
Rafael Espindola
9d46e81a8b Don't preserve all symbols in a .so and instead trust gold to know what is
needed. The result is that now we are able to drop unnecessary symbol from
shared libraries.

llvm-svn: 105389
2010-06-03 14:45:44 +00:00
Rafael Espindola
aa7f3b0561 Avoid renaming loadable modules at install time. Now the gold plugin is named
LLVMgold.so both in both the build and install directories.

llvm-svn: 103897
2010-05-16 03:13:23 +00:00
Rafael Espindola
bc6fabbd3e Add an also-emit-llvm option to the gold plugin.
llvm-svn: 103714
2010-05-13 13:39:31 +00:00
Nick Lewycky
e96e382131 Revert r64616 which worked around http://gcc.gnu.org/PR42757 , we just didn't
know it at the time.

llvm-svn: 101439
2010-04-16 04:32:20 +00:00
Dan Gohman
499f38cfcb Create an exports file, so that the plugin only exports the onload symbol.
llvm-svn: 101431
2010-04-16 00:43:25 +00:00
Dan Gohman
792df0f4ca Make things static that don't need to be referenced from outside the file.
llvm-svn: 101430
2010-04-16 00:42:57 +00:00
Chris Lattner
5a57121631 make -fno-rtti the default unless a directory builds with REQUIRES_RTTI.
llvm-svn: 94378
2010-01-24 20:43:08 +00:00
Chris Lattner
276811b58a Stop building RTTI information for *most* llvm libraries. Notable
missing ones are libsupport, libsystem and libvmcore.  libvmcore is
currently blocked on bugpoint, which uses EH.  Once it stops using
EH, we can switch it off.

This #if 0's out 3 unit tests, because gtest requires RTTI information.
Suggestions welcome on how to fix this.

llvm-svn: 94164
2010-01-22 06:49:46 +00:00
Viktor Kutuzov
4da1a5215a Fix to pass options from Gold plugin to LTO codegen
llvm-svn: 85419
2009-10-28 18:55:55 +00:00
Duncan Sands
728eebe8e2 Include config.h in order to have HAVE_STDINT_H be defined.
In the latest binutils the plugin-api.h needs this - without
it the LLVM gold plugin fails to compile.

llvm-svn: 84861
2009-10-22 16:03:32 +00:00
Nick Lewycky
4c87d257a4 Fix Makefile to build correctly on Darwin. Patch by Sandeep Patel!
llvm-svn: 83813
2009-10-11 23:10:09 +00:00
Dan Gohman
53f0d68f87 Make LLVM command-line tools overwrite their output files without -f.
This is conventional command-line tool behavior. -f now just means
"enable binary output on terminals".

Add a -f option to llvm-extract and llvm-link, for consistency.

Remove F_Force from raw_fd_ostream and enable overwriting and
truncating by default. Introduce an F_Excl flag to permit users to
enable a failure when the file already exists. This flag is
currently unused.

Update Makefiles and documentation accordingly.

llvm-svn: 79990
2009-08-25 15:34:52 +00:00
Chris Lattner
f16d8ade4f Change raw_fd_ostream to take flags as an optional bitmask
instead of as two bools.  Use this to add a F_Append flag
which has the obvious behavior.

Other unrelated changes conflated into this patch:

1. REmove EH stuff from llvm-dis and llvm-as, the try blocks
   are dead.
2. Simplify the filename inference code in llvm-as/llvm-dis,
   because raw_fd_ostream does the right thing with '-'.
3. Switch machine verifier to use raw_ostream instead of ostream
   (Which is the thing that needed append in the first place).

llvm-svn: 79807
2009-08-23 02:51:22 +00:00
Dan Gohman
9ced780576 Add a Force option to raw_fd_ostream to specify whether opening
an existing file is considered an error. Convert several tools
to use raw_fd_ostream instead of std::ostream, and to use this
new option instead of doing a manual check.

llvm-svn: 75801
2009-07-15 17:29:42 +00:00
Jeffrey Yasskin
29ea777c1e Add a portable strerror*() wrapper, llvm::sys::StrError(). This includes the
Windows variant, strerror_s, but I couldn't test that.

I'll update configure and config.h.in in a subsequent patch.

llvm-svn: 74621
2009-07-01 18:11:20 +00:00
Chris Lattner
07463b0a0a remove dead makefile flags.
llvm-svn: 74065
2009-06-24 05:29:56 +00:00
Rafael Espindola
904e6801af Remove the gcc= option. llvm-gcc uses only as=
Look for as in the path. Doing it here instead
of llvm-gcc because llvm-gcc has nothing as
convenient as sys::Program::FindProgramByName.

llvm-svn: 73383
2009-06-15 10:14:18 +00:00
Nick Lewycky
acd23348af Add option for specifying the path to assembler, "as". This overrides the path
to gcc.

llvm-svn: 73008
2009-06-07 00:50:45 +00:00
Duncan Sands
28cf31b990 Make sure the CXXFLAGS setting is picked up by
the common Makefile.  Not sure why this suddenly
started causing problems.

llvm-svn: 71925
2009-05-16 04:00:00 +00:00
Nick Lewycky
503cfd4ace Allow a user of libLTO to specify the full pathname of the gcc executable to
run when assembling.

Wire this up to the gold plugin. You can now pass --plugin-opt gcc=/foo/bar/gcc
and it will run that gcc instead of looking for it on the path.

llvm-svn: 70490
2009-04-30 15:24:09 +00:00
Rafael Espindola
b01a03d6d5 Add LTO_SYMBOL_DEFINITION_WEAKUNDEF, use that on the gold plugin.
llvm-svn: 69972
2009-04-24 16:55:21 +00:00
Nick Lewycky
2e90dfefff Force 'llvm-config' to go first, optionally followed by lto and gold mixed in
with the rest of the parallel directories.

Build lto when possible on all platforms. Make gold to explicitly depend on
libLTO.

llvm-svn: 65518
2009-02-26 07:56:49 +00:00
Nick Lewycky
9dc59d9c7b Add an option to the gold plugin to make it emit a file with the public api
list that can in turn be passed to -internalize pass through
-internalize-public-api-file.

Pass gold -plugin-opt=generate-api-file to produce "apifile.txt" in the current
directory.

llvm-svn: 65295
2009-02-22 22:15:44 +00:00
Rafael Espindola
86b3bf5add really fix style
llvm-svn: 64923
2009-02-18 17:49:06 +00:00
Rafael Espindola
3435277172 fix style
llvm-svn: 64905
2009-02-18 08:30:15 +00:00
Rafael Espindola
c5a5171d1b tools like nm and ar only need register_claim_file and add_symbols. Don't abort
if other hooks are missing.

llvm-svn: 64812
2009-02-17 21:08:21 +00:00
Nick Lewycky
6b1d3c472e Shoot! Remove this debugging line again!
llvm-svn: 64617
2009-02-15 22:50:17 +00:00
Nick Lewycky
c3eb6707e6 Don't discard definitions of common symbols. Not sure if this is the right fix.
Before this change, the program:
  int var;
  int main(void) { return 0; }
when run under 'nm -g' would show 'U var' with the gold plugin and
'B var' with gcc.

llvm-svn: 64616
2009-02-15 22:49:17 +00:00
Nick Lewycky
11dca311a6 Free the buffer in the case where we don't create a module out of it, as
pointed out by Torok Edwin.

Remove trailing whitespaces.

llvm-svn: 64002
2009-02-07 03:15:01 +00:00
Nick Lewycky
0f8a4bbb7e Free the buffer.
llvm-svn: 63907
2009-02-06 01:58:34 +00:00
Duncan Sands
134778fae1 Revert the previous commit. It seems it didn't
really solve the problem.  Also it changed the
name from libLLVMgold to LLVMgold (correcting
the name resulted in the original problem
suddenly reappearing).

llvm-svn: 63861
2009-02-05 10:21:34 +00:00
Duncan Sands
9ae3dee83e Stop llvm-config thinking that there are circular
dependencies between libraries due to __dso_handle
when doing "make install".  I don't know what the
LINK_COMPONENTS stuff is about, so I left it alone.

llvm-svn: 63860
2009-02-05 09:54:02 +00:00
Nick Lewycky
7c25f31e98 It's not obvious, but lto_module_create_from_memory doesn't need to use the
buffer after it creates the Module. Thus, we don't need to store this pointer
in claimed_file.

llvm-svn: 63834
2009-02-05 05:36:01 +00:00
Nick Lewycky
43c102836a Remove accidentally included debug message!
Reword a comment for clarity. Remove some extra whitespace.

llvm-svn: 63823
2009-02-05 04:14:23 +00:00
Torok Edwin
cd96136848 Alphabetize includes. Update comment.
llvm-svn: 63771
2009-02-04 21:00:02 +00:00
Torok Edwin
04de24510f mention that PIC is needed for libLTO and libLLVMgold
llvm-svn: 63755
2009-02-04 19:12:25 +00:00
Torok Edwin
b3017f3e09 remove printf - it was there only for debugging!
llvm-svn: 63742
2009-02-04 17:40:28 +00:00
Torok Edwin
36cbde673b add support for .a files containing LLVM IR to the gold plugin
llvm-svn: 63741
2009-02-04 17:39:30 +00:00
Nick Lewycky
23adb71f2a Add LLVM plugin for gold.
llvm-svn: 63623
2009-02-03 07:13:24 +00:00