Commit Graph

210 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
bff2c565df Fix build error from r234957
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234958 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-15 00:13:51 +00:00
Duncan P. N. Exon Smith
657aad675a 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234957 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-15 00:10:50 +00:00
Rafael Espindola
427c073035 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 :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234535 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 21:06:08 +00:00
Rafael Espindola
a93117c50d 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234495 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 15:54:59 +00:00
Rafael Espindola
23295f613b 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234461 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 02:28:12 +00:00
Rafael Espindola
a55ae077e4 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233603 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 21:36:43 +00:00
Rafael Espindola
ac406dfb70 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233381 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 15:55:06 +00:00
Peter Collingbourne
416d8ecf80 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232769 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:01:00 +00:00
Rafael Espindola
dc6141a4ff 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 :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232221 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 21:54:20 +00:00
Rafael Espindola
671944ff8f Fix the build of the gold-plugin and examples.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231279 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 19:15:29 +00:00
Rafael Espindola
c90e7f79ca 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231273 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 18:51:45 +00:00
NAKAMURA Takumi
69de0932a5 Revert r231132, "Correctly handle -pass-remarks in the gold plugin.", for now, to suppress log floodng in LTO.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231253 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 16:24:28 +00:00
Rafael Espindola
0685d06674 Correctly handle -pass-remarks in the gold plugin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231132 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-03 21:11:13 +00:00
Rafael Espindola
de833240aa 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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230991 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02 19:08:03 +00:00
NAKAMURA Takumi
a18f49225a 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230885 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-01 04:16:28 +00:00
Rafael Espindola
8d4343eb9b 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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230655 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-26 18:24:37 +00:00
Rafael Espindola
7ef23e62b2 Set the datalayout in the gold plugin.
This fixes the gold tests after r230054.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230098 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-21 00:13:15 +00:00
Chandler Carruth
15db81893f [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229251 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-14 09:43:57 +00:00
Chandler Carruth
29a861abc9 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229156 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 21:10:58 +00:00
Chandler Carruth
417c5c172c [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".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229094 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 10:01:29 +00:00
Michael Kuperstein
17a113d26b 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>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228946 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-12 18:21:50 +00:00
Jan Wen Voung
0dfec56734 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-11 16:12:50 +00:00
NAKAMURA Takumi
b497e12c65 gold-plugin.cpp: Fixup r227599 corresponding to r227685 and r227731 -- Don't lose DataLayoutPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227783 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 05:47:30 +00:00
Alexey Samsonov
9b8adaf3b2 Fixup gold-plugin after r227576.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227599 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-30 19:14:04 +00:00
Sylvestre Ledru
f85bc8ac5a Update of the gold-plugin.cpp code to match Chandler's changes (r226981)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227004 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-24 13:59:08 +00:00
Chandler Carruth
bda134910a [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226078 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 02:16:27 +00:00
Rafael Espindola
0a2caa143f Fix linking of shared libraries.
In shared libraries the plugin can see non-weak declarations that are still
undefined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226031 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 20:08:46 +00:00
Rafael Espindola
55c86a8cdc Fix handling of extern_weak. This was broken by r225983.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226026 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 19:43:32 +00:00
Rafael Espindola
5f92811f30 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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225983 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 13:53:50 +00:00
Rafael Espindola
68016e0a6e 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225562 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-10 00:07:30 +00:00
Rafael Espindola
3d1c71a3d8 Fix a leak found by asan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224776 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-23 18:18:37 +00:00
Rafael Espindola
d3732d9095 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223863 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-10 00:09:35 +00:00
Rafael Espindola
075a8cee5d Rename createIRObjectFile to just create.
It is a static method of IRObjectFile, so having to use
IRObjectFile::createIRObjectFile was redundant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223822 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 20:36:13 +00:00
Rafael Espindola
f214fe8b32 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223790 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 16:50:57 +00:00
Rafael Espindola
4f20ed1c36 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223780 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 16:13:59 +00:00
Rafael Espindola
33f1a430c2 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223481 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-05 17:25:52 +00:00
Rafael Espindola
2fbbd7a369 gold plugin: call llvm_shutdown so that -stats works.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 20:52:49 +00:00
Rafael Espindola
f1ca1d4bc3 Add a disable-output option to the gold plugin.
This corresponds to the opt option and is handy for profiling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222687 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-24 21:18:14 +00:00
Duncan P. N. Exon Smith
d871594be4 gold-plugin: Fix typo in error message
Spotted while reading code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222395 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 22:39:21 +00:00
Rafael Espindola
fc095209b8 Fix the build of the gold plugin.
I did the previous patch on OS X and didn't noticed the issue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221070 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-01 23:49:44 +00:00
Rafael Espindola
5793838fc8 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221050 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-01 16:46:18 +00:00
Rafael Espindola
d07e7ecd85 Enable the slp vectorizer in the gold plugin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220887 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30 00:38:54 +00:00
Rafael Espindola
74ded7c790 Enable the loop vectorizer in the gold plugin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220886 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30 00:11:24 +00:00
Rafael Espindola
25016f9d2e 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220885 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29 23:54:45 +00:00
Rafael Espindola
e272236d69 Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220610 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-25 04:07:53 +00:00
Rafael Espindola
72478e59c7 Update the error handling of lib/Linker.
Instead of passing a std::string&, use the new diagnostic infrastructure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220608 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-25 04:06:10 +00:00
Rafael Espindola
c498284e46 Modernize the error handling of the Materialize function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220600 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24 22:50:48 +00:00
Rafael Espindola
68b02dcd54 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220580 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24 18:13:04 +00:00
Rafael Espindola
f9ebe0ad75 Fix a gcc warning.
Thanks to Filipe Cabecinhas for the report.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220361 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-22 02:23:31 +00:00
Rafael Espindola
a447422da3 Fix gcc warning in gold-plugin.cpp.
Patch by Markus Trippelsdorf!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219459 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 00:48:13 +00:00