Commit Graph

25 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
f5d17528ee Module: Don't rename in getOrInsertFunction()
During LTO, user-supplied definitions of C library functions often
exist.  -instcombine uses Module::getOrInsertFunction() to get a handle
on library functions (e.g., @puts, when optimizing @printf).

Previously, Module::getOrInsertFunction() would rename any matching
functions with local linkage, and create a new declaration.  In LTO,
this is the opposite of desired behaviour, as it skips by the
user-supplied version of the library function and creates a new
undefined reference which the linker often cannot resolve.

After some discussing with Rafael on the list, it looks like it's
undesired behaviour.  If a consumer actually *needs* this behaviour, we
should add new API with a more explicit name.

I added two testcases: one specifically for the -instcombine behaviour
and one for the LTO flow.

<rdar://problem/16165191>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203513 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-10 23:42:28 +00:00
Rafael Espindola
737c9f6005 Add back r201608, r201622, r201624 and r201625
r201608 made llvm corretly handle private globals with MachO. r201622 fixed
a bug in it and r201624 and r201625 were changes for using private linkage,
assuming that llvm would do the right thing.

They all got reverted because r201608 introduced a crash in LTO. This patch
includes a fix for that. The issue was that TargetLoweringObjectFile now has
to be initialized before we can mangle names of private globals. This is
trivially true during the normal codegen pipeline (the asm printer does it),
but LTO has to do it manually.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201700 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-19 17:23:20 +00:00
Rafael Espindola
1e75dec97a Don't internalize linkonce_odr non constant variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200983 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-07 19:04:43 +00:00
Rafael Espindola
a73e920f09 Provide a dummy section to fix a crash with inline assembly in LTO.
Fixes pr18508.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199843 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 22:11:14 +00:00
Yi Jiang
41a3007571 Resubmit r196544: Apply transformation on OS X 10.9+ and iOS 7.0+: pow(10, x) ―> __exp10(x)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197109 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12 01:55:04 +00:00
Yi Jiang
7c2b072d69 Add TargetLibraryInfo in LTO passes builder
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197105 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12 01:37:39 +00:00
Justin Bogner
dc6b4b4fc2 Protect user-supplied runtime library functions in LTO
Add user-supplied C runtime and compiler-rt library functions to
llvm.compiler.used to protect them from premature optimization by
passes like -globalopt and -ipsccp.  Calls to (seemingly unused)
runtime library functions can be added by -instcombine and instruction
lowering.

Patch by Duncan Exon Smith, thanks!

Fixes <rdar://problem/14740087>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194514 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-12 21:44:01 +00:00
Rafael Espindola
bd2affeab4 A better fix that also works on ppc: add a target tripple.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193915 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-02 06:00:09 +00:00
Rafael Espindola
e62e056766 Fix this test to pass on darwin now that llvm-nm is working.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193914 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-02 05:29:22 +00:00
Rafael Espindola
56ca8b3059 Use \01 to disable the mangler. Should fix the 32 bit windows bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193846 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-01 01:14:20 +00:00
Rafael Espindola
53446e50a0 Relax check line to match what llvm-nm prints for COFF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193810 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 22:07:46 +00:00
Rafael Espindola
fe0ae1db3a XFAIL on ppc64 too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193804 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 21:27:02 +00:00
Rafael Espindola
6af049837a XFAIL this for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193802 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 21:22:43 +00:00
Rafael Espindola
7e667c56cf 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193800 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 20:51:58 +00:00
Rafael Espindola
713cab059e Optimize more linkonce_odr values during LTO.
When a linkonce_odr value that is on the dso list is not unnamed_addr
we can still look to see if anything is actually using its address. If
not, it is safe to hide it.

This patch implements that by moving GlobalStatus to Transforms/Utils
and using it in Internalize.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193090 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-21 17:14:55 +00:00
NAKAMURA Takumi
8bb2a23a1d llvm/test/LTO should run also on cygwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192262 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-09 01:07:31 +00:00
Rafael Espindola
ec2ac89856 Fix object file writing in llvm-lto on Windows.
We were writing in text mode.

Patch by Greg Bedwell.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191985 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-04 21:40:54 +00:00
Rafael Espindola
438900938c 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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191922 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-03 18:29:09 +00:00
Rafael Espindola
656d2f8e07 Try harder to disable the LTO tests on windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191836 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 15:47:30 +00:00
Rafael Espindola
4459def5d1 Disable this test on Win32 for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191830 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 14:48:35 +00:00
Rafael Espindola
b964366a9a Add a -exported-symbol option to llvm-lto.
Patch by Tom Roeder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191825 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 14:12:56 +00:00
Rafael Espindola
2be8ab4603 Enable building LTO on WIN32.
Enable building the LTO library (.lib and.dll) and llvm-lto.exe on Windows with
MSVC and Mingw as well as re-enabling the associated test.

Patch by Greg Bedwell!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191823 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 14:04:38 +00:00
Rafael Espindola
4b5205d2a3 Revert "Enable building LTO on WIN32."
This reverts commit r191670.

It was causing build failures on the msvc bots:

http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/5166/steps/compile/logs/stdio

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-30 16:32:51 +00:00
Rafael Espindola
a5b9cd1c68 Enable building LTO on WIN32.
Enable building the LTO library (.lib and.dll) and llvm-lto.exe on Windows with
MSVC and Mingw as well as re-enabling the associated test.

Patch by Greg Bedwell!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191670 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-30 15:28:14 +00:00
Peter Collingbourne
cc48854d5d Move LTO support library to a component, allowing it to be tested
more reliably across platforms.  Patch by Tom Roeder!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191343 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-24 23:52:22 +00:00