1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

386 Commits

Author SHA1 Message Date
Rafael Espindola
69b537cdd4 Disable use list order on the gold plugin.
It turns out that his is *really* slow. With this change the link of
clang with plugin-opt=emit-llvm goes from 41 to 26 seconds.

We can add an option to enable it again if needed.

llvm-svn: 256302
2015-12-22 23:45:49 +00:00
Teresa Johnson
c78d28935d Use LLVM style variable name (NFC)
Fixes variable name from r255779.

llvm-svn: 255824
2015-12-16 21:37:48 +00:00
Teresa Johnson
110b342ed8 Add RAII wrapper for gold plugin file management
Suggested in review of r255256.

llvm-svn: 255779
2015-12-16 16:34:06 +00:00
Rafael Espindola
5b397256de Use diagnostic handler in the LLVMContext
This patch converts code that has access to a LLVMContext to not take a
diagnostic handler.

This has a few advantages

* It is easier to use a consistent diagnostic handler in a single program.
* Less clutter since we are not passing a handler around.

It does make it a bit awkward to implement some C APIs that return a
diagnostic string. I will propose new versions of these APIs and
deprecate the current ones.

llvm-svn: 255571
2015-12-14 23:17:03 +00:00
Teresa Johnson
99c029d45a [ThinLTO] Release files in gold plugin during combined index (take 2)
Ensure we release the files even when they don't hold a function index
summary section, by restructuring the control flow a little bit.

llvm-svn: 255256
2015-12-10 16:11:23 +00:00
Rafael Espindola
c944447e56 Slit lib/Linker in two.
A linker normally has two stages: symbol resolution and "moving stuff".

In lib/Linker there is the complication of lazy linking some globals,
but it was still far more mixed than it needed to.

This splits the linker into a lower level IRMover and the linker proper.
The IRMover just takes a list of globals to move and a callback that
lets the user control what is lazy linked.

The main motivation is that now tools/gold (and soon lld) can use their
own symbol resolution to instruct IRMover what to do.

llvm-svn: 255254
2015-12-10 14:19:35 +00:00
Teresa Johnson
f07f0a51b6 [ThinLTO] Release files read when creating combined index in gold plugin
This wasn't causing an issue since at HEAD we exit the linker completely
after creating the combined index.

llvm-svn: 255156
2015-12-09 21:11:42 +00:00
Teresa Johnson
cd4a1a051d Delay context construction to when/if it is needed in gold plugin (NFC)
llvm-svn: 255146
2015-12-09 19:49:40 +00:00
Teresa Johnson
b82193e4a3 clang-format order of gold-plugin includes (NFC)
llvm-svn: 255144
2015-12-09 19:45:55 +00:00
Rafael Espindola
2c7e9b8d27 Always pass a diagnostic handler to the linker.
Before this patch the diagnostic handler was optional. If it was not
passed, the one in the LLVMContext was used.

That is probably not a pattern we want to follow. If each area has an
optional callback, there is a sea of callbacks and it is hard to follow
which one is called.

Doing this also found cases where the callback is a nice addition, like
testing that no errors or warnings are reported.

The other option is to always use the diagnostic handler in the
LLVMContext. That has a few problems

* To implement the C API we would have to set the diag handler and then
  set it back to the original value.
* Code that creates the context might be far away from code that wants
  the diagnostics.

I do have a patch that implements the second option and will send that as
an RFC.

llvm-svn: 254777
2015-12-04 22:08:53 +00:00
Rafael Espindola
e3fda2ca99 Use references now that it is natural to do so.
The linker never takes ownership of a module or changes which module it
is refering to, making it natural to use references.

llvm-svn: 254449
2015-12-01 19:50:54 +00:00
Rafael Espindola
4a063d8813 Simplify the linking of recursive data.
Now the ValueMapper has two callbacks. The first one maps the
declaration. The ValueMapper records the mapping and then materializes
the body/initializer.

llvm-svn: 254209
2015-11-27 20:28:19 +00:00
Rafael Espindola
bdc0b27af4 Don't create implicit comdats.
comdats are explicitly represented for some time now.

llvm-svn: 253924
2015-11-23 22:01:51 +00:00
Teresa Johnson
2b4369dd03 [ThinLTO] Handle bitcode without function summary sections gracefully
Summary:
Several fixes to the handling of bitcode files without function summary
sections so that they are skipped during ThinLTO processing in llvm-lto
and the gold plugin when appropriate instead of aborting.

1 Don't assert when trying to add a FunctionInfo that doesn't have
  a summary attached.
2 Skip FunctionInfo structures that don't have attached function summary
  sections when trying to create the combined function summary.
3 In both llvm-lto and gold-plugin, check whether a bitcode file has
  a function summary section before trying to parse the index, and skip
  the bitcode file if it does not.
4 Fix hasFunctionSummaryInMemBuffer in BitcodeReader, which had a bug
  where we returned to early while looking for the summary section.

Also added llvm-lto and gold-plugin based tests for cases where we
don't have function summaries in the bitcode file. I verified that
either the first couple fixes described above are enough to avoid the
crashes, or fixes 1,3,4. But have combined them all here for added
robustness.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

llvm-svn: 253796
2015-11-21 21:55:48 +00:00
Mehdi Amini
4a5d6965a4 Remove unused function parameter (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 253569
2015-11-19 15:42:34 +00:00
NAKAMURA Takumi
ce69d484e2 gold-plugin.cpp: Fix diagnosticHandler corresponding to r253540.
llvm-svn: 253553
2015-11-19 10:43:44 +00:00
Teresa Johnson
1cf56803da Clang format a few prior patches (NFC)
I had clang formatted my earlier patches using the wrong style.
Reformatted with the LLVM style.

llvm-svn: 251812
2015-11-02 18:02:11 +00:00
Manuel Klimek
fa13a98a8a Make class final to pacify -Wnon-virtual-dtor.
llvm-svn: 250805
2015-10-20 08:21:01 +00:00
Teresa Johnson
4655ffb0a6 Pass FunctionInfoIndex by reference to WriteFunctionSummaryToFile (NFC)
Implemented suggestion by dblakie in review for r250704.

llvm-svn: 250723
2015-10-19 19:06:06 +00:00
Teresa Johnson
0fb3f39b16 Convert gold-plugin unnecessary unique_ptr into local (NFC)
llvm-svn: 250704
2015-10-19 15:23:03 +00:00
Teresa Johnson
091cf86389 Support for function summary index bitcode sections and files.
Summary:
The bitcode format is described in this document:
  https://drive.google.com/file/d/0B036uwnWM6RWdnBLakxmeDdOeXc/view
For more info on ThinLTO see:
  https://sites.google.com/site/llvmthinlto

The first customer is ThinLTO, however the data structures are designed
and named more generally based on prior feedback. There are a few
comments regarding how certain interfaces are used by ThinLTO, and the
options added here to gold currently have ThinLTO-specific names as the
behavior they provoke is currently ThinLTO-specific.

This patch includes support for generating per-module function indexes,
the combined index file via the gold plugin, and several tests
(more are included with the associated clang patch D11908).

Reviewers: dexonsmith, davidxl, joker.eph

Subscribers: llvm-commits

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

llvm-svn: 249270
2015-10-04 14:33:43 +00:00
Teresa Johnson
78568b0dfc Disable the second verification run when performing LTO through
gold in NDEBUG mode.
Follow on patch for r247729 - LTO: Disable extra verify runs in release
builds.

llvm-svn: 247824
2015-09-16 18:06:45 +00:00
Peter Collingbourne
3ca4de04cf gold-plugin: Implement parallel LTO code generation using llvm::splitCodeGen.
Parallelism can be enabled using a new plugin option, jobs=N, where N is
the number of code generation threads.

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

llvm-svn: 246584
2015-09-01 20:40:22 +00:00
Nick Lewycky
9475c2ee80 Replace &vector[0] with vector.data() to avoid invalid dereference caught by debug STL. Also move a '*' for consistency and fix an 80-col violation.
llvm-svn: 244134
2015-08-05 21:16:02 +00:00
Chandler Carruth
60c1597466 Update for r243115 which changed the DataLayout API on TargetMachine but
didn't update the gold-plugin.

llvm-svn: 243121
2015-07-24 17:23:09 +00:00
Rafael Espindola
6f06c96f52 gold-plugin: save the .o when given -save-temps.
The plugin now save the bitcode before and after optimizations and the
.o that is passed to the linker.

llvm-svn: 239726
2015-06-15 13:36:27 +00:00
Duncan P. N. Exon Smith
9a09dfde5f Fix build error from r234957
llvm-svn: 234958
2015-04-15 00:13:51 +00:00
Duncan P. N. Exon Smith
b222408637 uselistorder: Pull the bit through WriteToBitcodFile()
Change the callers of `WriteToBitcodeFile()` to pass `true` or
`shouldPreserveBitcodeUseListOrder()` explicitly.  I left the callers
that want to send `false` alone.

I'll keep pushing the bit higher until hopefully I can delete the global
`cl::opt` entirely.

llvm-svn: 234957
2015-04-15 00:10:50 +00:00
Rafael Espindola
a7ececf04c Simplify use of formatted_raw_ostream.
formatted_raw_ostream is a wrapper over another stream to add column and line
number tracking.

It is used only for asm printing.

This patch moves the its creation down to where we know we are printing
assembly. This has the following advantages:

* Simpler lifetime management: std::unique_ptr
* We don't compute column and line number of object files :-)

llvm-svn: 234535
2015-04-09 21:06:08 +00:00
Rafael Espindola
edd11eb538 This reverts commit r234460 and r234461.
Revert "Add classof implementations to the raw_ostream classes."
Revert "Use the cast machinery to remove dummy uses of formatted_raw_ostream."

The underlying issue can be fixed without classof.

llvm-svn: 234495
2015-04-09 15:54:59 +00:00
Rafael Espindola
4b3ef31279 Use the cast machinery to remove dummy uses of formatted_raw_ostream.
If we know we are producing an object, we don't need to wrap the stream
in a formatted_raw_ostream anymore.

llvm-svn: 234461
2015-04-09 02:28:12 +00:00
Rafael Espindola
d4994c3c6d Fix PR23045.
Keep a note in the materializer that we are stripping debug info so that
user doing a lazy read of the module don't hit outdated formats.

Thanks to Duncan for suggesting the fix.

llvm-svn: 233603
2015-03-30 21:36:43 +00:00
Rafael Espindola
951d9d1379 Work around pr23045 and make it easier to reproduce.
Dropping old debug format requires the entire module to be read upfront.

This was failing only with the gold plugin, but that is just because
llvm-link was not upgrading metadata.

The new testcase using llvm-link shows the problem.

llvm-svn: 233381
2015-03-27 15:55:06 +00:00
Peter Collingbourne
3bdbf14413 libLTO, llvm-lto, gold: Introduce flag for controlling optimization level.
This change also introduces a link-time optimization level of 1. This
optimization level runs only the globaldce pass as well as cleanup passes for
passes that run at -O0, specifically simplifycfg which cleans up lowerbitsets.

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150316/266951.html

llvm-svn: 232769
2015-03-19 22:01:00 +00:00
Rafael Espindola
20325e7adb Be lazy about loading metadata in IRObjectFile.
This speeds up llvm-ar building lib64/libclangSema.a with debug IR files
from 8.658015807 seconds to just 0.351036519 seconds :-)

llvm-svn: 232221
2015-03-13 21:54:20 +00:00
Rafael Espindola
ca14ac8847 Fix the build of the gold-plugin and examples.
llvm-svn: 231279
2015-03-04 19:15:29 +00:00
Rafael Espindola
1d5108b4c0 Bring r231132 back with a fix.
The issue was that we were always printing the remarks. Fix that and add a test
showing that it prints nothing if -pass-remarks is not given.

Original message:
Correctly handle -pass-remarks in the gold plugin.

llvm-svn: 231273
2015-03-04 18:51:45 +00:00
NAKAMURA Takumi
05c64af8c6 Revert r231132, "Correctly handle -pass-remarks in the gold plugin.", for now, to suppress log floodng in LTO.
llvm-svn: 231253
2015-03-04 16:24:28 +00:00
Rafael Espindola
5ebbc2fe84 Correctly handle -pass-remarks in the gold plugin.
llvm-svn: 231132
2015-03-03 21:11:13 +00:00
Rafael Espindola
5d476a38b8 Add r230655 back with a fix.
The issue is that now we have a diag handler during optimizations
and get forward every optimization remark, flooding stdout.

The same filtering should probably be done with or without a
custom handler, but for now just ignore remarks.

Original message:

gold-plugin: "Upgrade" debug info and handle its warnings.

The gold plugin never calls MaterializeModule, so any old debug info
was not deleted and could cause crashes.

Now that it is being "upgraded", the plugin also has to handle warnings
and create Modules with a nice id (it shows in the warning).

llvm-svn: 230991
2015-03-02 19:08:03 +00:00
NAKAMURA Takumi
f23d837ff0 Revert r230655, "gold-plugin: "Upgrade" debug info and handle its warnings."
It emits *millions of warnings* during selfhosting LTO build, to choke the buildbot with gigbytes of log.

llvm-svn: 230885
2015-03-01 04:16:28 +00:00
Rafael Espindola
b62b482b34 gold-plugin: "Upgrade" debug info and handle its warnings.
The gold plugin never calls MaterializeModule, so any old debug info
was not deleted and could cause crashes.

Now that it is being "upgraded", the plugin also has to handle warnings
and create Modules with a nice id (it shows in the warning).

llvm-svn: 230655
2015-02-26 18:24:37 +00:00
Rafael Espindola
5cb9b32cc4 Set the datalayout in the gold plugin.
This fixes the gold tests after r230054.

llvm-svn: 230098
2015-02-21 00:13:15 +00:00
Chandler Carruth
735d694283 [gold] Consolidate the gold plugin options and actually search for
a gold binary explicitly. Substitute this binary into the tests rather
than just directly executing the 'ld' binary.

This should allow folks to inject a cross compiling gold binary, or in
my case to use a gold binary built and installed somewhere other than
/usr/bin/ld. It should also allow the tests to find 'ld.gold' so that
things work even if gold isn't the default on the system.

I've only stubbed out support in the makefile to preserve the existing
behavior with none of the fancy logic. If someone else wants to add
logic here, they're welcome to do so.

llvm-svn: 229251
2015-02-14 09:43:57 +00:00
Chandler Carruth
14908a5033 [PM] Fix a compile error I introduced in r229094 and didn't notice
because I didn't have binutils set up properly to build the gold plugin.

Fixes PR22581 which was filed because this broke the build for folks
relying on the plugin. Very sorry! =]

I've gotten the plugin stuff building now as well so it shouldn't keep
happening.

llvm-svn: 229156
2015-02-13 21:10:58 +00:00
Chandler Carruth
18e8c62883 [PM] Remove the old 'PassManager.h' header file at the top level of
LLVM's include tree and the use of using declarations to hide the
'legacy' namespace for the old pass manager.

This undoes the primary modules-hostile change I made to keep
out-of-tree targets building. I sent an email inquiring about whether
this would be reasonable to do at this phase and people seemed fine with
it, so making it a reality. This should allow us to start bootstrapping
with modules to a certain extent along with making it easier to mix and
match headers in general.

The updates to any code for users of LLVM are very mechanical. Switch
from including "llvm/PassManager.h" to "llvm/IR/LegacyPassManager.h".
Qualify the types which now produce compile errors with "legacy::". The
most common ones are "PassManager", "PassManagerBase", and
"FunctionPassManager".

llvm-svn: 229094
2015-02-13 10:01:29 +00:00
Michael Kuperstein
8f320b0aec gold-plugin: delete the output file for OT_DISABLE
bfd creates the output file early, so calling exit(0) is not enough, the file needs to be explicitly deleted.

Patch by: H.J. Lu <hjl.tools@gmail.com>

llvm-svn: 228946
2015-02-12 18:21:50 +00:00
Jan Wen Voung
ea1b991ecf Gold-plugin: Broaden scope of get/release_input_file to scope of Module.
Summary:
Move calls to get_input_file and release_input_file out of
getModuleForFile(). Otherwise release_input_file may end up
unmapping a view of the file while the view is still being
used by the Module (on 32-bit hosts).

Fix for PR22482.

Test Plan: Add test using --no-map-whole-files.

Reviewers: rafael, nlewycky

Subscribers: llvm-commits

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

llvm-svn: 228842
2015-02-11 16:12:50 +00:00
NAKAMURA Takumi
e7b99ea1bf gold-plugin.cpp: Fixup r227599 corresponding to r227685 and r227731 -- Don't lose DataLayoutPass.
llvm-svn: 227783
2015-02-02 05:47:30 +00:00
Alexey Samsonov
a097d65d84 Fixup gold-plugin after r227576.
llvm-svn: 227599
2015-01-30 19:14:04 +00:00
Sylvestre Ledru
75cf88b1ce Update of the gold-plugin.cpp code to match Chandler's changes (r226981)
llvm-svn: 227004
2015-01-24 13:59:08 +00:00
Chandler Carruth
49a7633378 [PM] Move TargetLibraryInfo into the Analysis library.
While the term "Target" is in the name, it doesn't really have to do
with the LLVM Target library -- this isn't an abstraction which LLVM
targets generally need to implement or extend. It has much more to do
with modeling the various runtime libraries on different OSes and with
different runtime environments. The "target" in this sense is the more
general sense of a target of cross compilation.

This is in preparation for porting this analysis to the new pass
manager.

No functionality changed, and updates inbound for Clang and Polly.

llvm-svn: 226078
2015-01-15 02:16:27 +00:00
Rafael Espindola
d5fe70d054 Fix linking of shared libraries.
In shared libraries the plugin can see non-weak declarations that are still
undefined.

llvm-svn: 226031
2015-01-14 20:08:46 +00:00
Rafael Espindola
75b9d612a7 Fix handling of extern_weak. This was broken by r225983.
llvm-svn: 226026
2015-01-14 19:43:32 +00:00
Rafael Espindola
ae29621e74 Handle a symbol being undefined.
This can happen if:
* It is present in a comdat in one file.
* It is not present in the comdat of the file that is kept.
* Is is not used.

This should fix the LTO boostrap.

Thanks to Takumi NAKAMURA for setting up the bot!

llvm-svn: 225983
2015-01-14 13:53:50 +00:00
Rafael Espindola
3ca4721c27 Use the DiagnosticHandler to print diagnostics when reading bitcode.
The bitcode reading interface used std::error_code to report an error to the
callers and it is the callers job to print diagnostics.

This is not ideal for error handling or diagnostic reporting:

* For error handling, all that the callers care about is 3 possibilities:
  * It worked
  * The bitcode file is corrupted/invalid.
  * The file is not bitcode at all.

* For diagnostic, it is user friendly to include far more information
  about the invalid case so the user can find out what is wrong with the
  bitcode file. This comes up, for example, when a developer introduces a
  bug while extending the format.

The compromise we had was to have a lot of error codes.

With this patch we use the DiagnosticHandler to communicate with the
human and std::error_code to communicate with the caller.

This allows us to have far fewer error codes and adds the infrastructure to
print better diagnostics. This is so because the diagnostics are printed when
he issue is found. The code that detected the problem in alive in the stack and
can pass down as much context as needed. As an example the patch updates
test/Bitcode/invalid.ll.

Using a DiagnosticHandler also moves the fatal/non-fatal error decision to the
caller. A simple one like llvm-dis can just use fatal errors. The gold plugin
needs a bit more complex treatment because of being passed non-bitcode files. An
hypothetical interactive tool would make all bitcode errors non-fatal.

llvm-svn: 225562
2015-01-10 00:07:30 +00:00
Rafael Espindola
f9dc0ab110 Fix a leak found by asan.
llvm-svn: 224776
2014-12-23 18:18:37 +00:00
Rafael Espindola
e8bfa7e348 Simplify the handling of aliases in the gold plugin.
The complicated situation is when we have to keep an alias but drop a GV
that is part of the aliasee.

We used to clone the dropped GV and make the clone internal. This is wasteful
as we know the original will be dropped.

With this patch what is done instead is set the linkage of the original to
internal and replace all uses (but the one in the alias) with a new
declaration that takes the name of the old GV. This saves us from having
to copy the body.

llvm-svn: 223863
2014-12-10 00:09:35 +00:00
Rafael Espindola
52a8798c70 Rename createIRObjectFile to just create.
It is a static method of IRObjectFile, so having to use
IRObjectFile::createIRObjectFile was redundant.

llvm-svn: 223822
2014-12-09 20:36:13 +00:00
Rafael Espindola
6f709341b7 Remember the unmangled name in the plugin.
This allows it to work with non trivial manglings like the one in COFF.

Amusingly, this can be tested with gold, as emit-llvm causes the plugin to
exit before any COFF is generated.

llvm-svn: 223790
2014-12-09 16:50:57 +00:00
Rafael Espindola
6a6bc11916 Don't lookup an object symbol name in the module.
Instead, walk the obj symbol list in parallel to find the GV. This shouldn't
change anything on ELF where global symbols are not mangled, but it is a step
toward supporting other object formats.

Gold itself is ELF only, but bfd ld supports COFF and the logic in the gold
plugin could be reused on lld.

llvm-svn: 223780
2014-12-09 16:13:59 +00:00
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