Commit Graph

458 Commits

Author SHA1 Message Date
Rafael Espindola 77f1f8f170 Remove lto_codegen_set_attr.
It was never exported, so no functionality change.

llvm-svn: 214519
2014-08-01 14:57:05 +00:00
NAKAMURA Takumi 5cc4606378 [CMake] tools/lto: Prune redundant libdep(s).
llvm-svn: 213855
2014-07-24 11:44:44 +00:00
Rafael Espindola adf21f2a56 Update the MemoryBuffer API to use ErrorOr.
llvm-svn: 212405
2014-07-06 17:43:13 +00:00
Rafael Espindola d749fb5129 Change LTOModule`s getTargetTriple and setTargetTriple to use c++ types.
llvm-svn: 212343
2014-07-04 14:19:41 +00:00
Alp Toker ac90380b5e Sink undesirable LTO functions into the old C API
We want to encourage users of the C++ LTO API to reuse memory buffers instead
of repeatedly opening and reading the same file contents.

This reverts commit r212305 and implements a tidier scheme.

llvm-svn: 212308
2014-07-04 00:58:41 +00:00
Peter Collingbourne 63086fe166 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
Rafael Espindola 3ef98ff5f9 Don't force the build of toos/lto as a static lib.
Any uses of tools/lto as a static lib should probably move to lib/LTO.
This was also never implemented in the configure build, so this reduces
the differences among the two.

llvm-svn: 211852
2014-06-27 02:51:21 +00:00
Alp Toker ec9b42a907 Remove unused includes following r211294
llvm-svn: 211297
2014-06-19 19:25:49 +00:00
Rafael Espindola 77c50d2394 Use the c++ APIs.
No functionality change.

llvm-svn: 211294
2014-06-19 19:11:22 +00:00
Patrik Hagglund 9be9d8725b Fix gcc -pedantic warning in lto.cpp.
llvm-svn: 207959
2014-05-05 12:24:08 +00:00
Rafael Espindola 83ceb8edfb Move LTOModule and LTOCodeGenerator to the llvm namespace.
llvm-svn: 207911
2014-05-03 14:59:52 +00:00
Rafael Espindola b62e6b4535 Style update: don't duplicate comments, they were getting out of sync.
llvm-svn: 207909
2014-05-03 14:34:48 +00:00
Tom Roeder fd1bc602b3 Add an -mattr option to the gold plugin to support subtarget features in LTO
This adds support for an -mattr option to the gold plugin and to llvm-lto. This
allows the caller to specify details of the subtarget architecture, like +aes,
or +ssse3 on x86.  Note that this requires a change to the include/llvm-c/lto.h
interface: it adds a function lto_codegen_set_attr and it increments the
version of the interface.

llvm-svn: 207279
2014-04-25 21:46:51 +00:00
Duncan P. N. Exon Smith 4680f40d28 Revert "Reapply "LTO: add API to set strategy for -internalize""
This reverts commit r199244.

Conflicts:
	include/llvm-c/lto.h
	include/llvm/LTO/LTOCodeGenerator.h
	lib/LTO/LTOCodeGenerator.cpp

llvm-svn: 205471
2014-04-02 22:05:57 +00:00
Rafael Espindola c80968e954 Centralize the handling of install_name and rpath.
This centralizes the Makefile handling of -install_name and -rpath. It also
moves the cmake build to using @rpath. The reason being that libclang needs it,
and it works for everything else.

A followup patch will move clang to using this and then there will be a single
point to edit to support other systems.

llvm-svn: 202499
2014-02-28 13:48:03 +00:00
NAKAMURA Takumi 9a51148cb5 [CMake] llvm-c/lto.h should be installed if libLTO.a is built.
llvm-svn: 201859
2014-02-21 14:57:09 +00:00
NAKAMURA Takumi 2fa24cc356 [CMake] libLTO: Use (SHARED|STATIC) to build both shared LTO and LTO_static.
llvm-svn: 201856
2014-02-21 14:17:43 +00:00
Eli Bendersky f0f210052f Refactor TargetOptions initialization into a single place.
The same code (~20 lines) for initializing a TargetOptions object from CodeGen
cmdline flags is duplicated 4 times in 4 different tools. This patch moves it
into a utility function.

Since the CodeGen/CommandFlags.h file defines cl::opt flags in a header, it's
a bit of a touchy situation because we should only link them into tools. So this
patch puts the init function in the header.

llvm-svn: 201699
2014-02-19 17:09:35 +00:00
Manman Ren 03456a176d LTO API: add lto_module_create_from_memory_with_path.
This function adds an extra path argument to lto_module_create_from_memory.
The path argument will be passed to makeBuffer to make sure the MemoryBuffer
has a name and the created module has a module identifier.

This is mainly for emitting warning messages from the linker. When we emit
warning message on a module, we can use the module identifier.

rdar://15985737

llvm-svn: 201114
2014-02-10 23:26:14 +00:00
NAKAMURA Takumi 6c406588d8 Revert r200560, "LTO itself hasn't depended on MCDisassembler any more."
Oh sorry, I missed LTO.exports, ... I checked just only *.cpp(s).

llvm-svn: 200562
2014-01-31 17:57:50 +00:00
NAKAMURA Takumi 56908b3401 LTO itself hasn't depended on MCDisassembler any more.
llvm-svn: 200560
2014-01-31 17:40:11 +00:00
Yunzhong Gao a88d7abeb1 Adding new LTO APIs to parse metadata nodes and extract linker options and
dependent libraries from a bitcode module.

Differential Revision: http://llvm-reviews.chandlerc.com/D2343

llvm-svn: 199759
2014-01-21 18:31:27 +00:00
Quentin Colombet 73a3b2209e Revert r199361: Now, the sanitizer got the change
llvm-svn: 199362
2014-01-16 07:29:07 +00:00
Quentin Colombet a823e8c266 [LTO] Modify lto.exports to force the sanitizer to rebuilt LTO.exports
llvm-svn: 199361
2014-01-16 07:14:01 +00:00
Quentin Colombet 5fa1f6f57a [LTO] Add a hook to map LLVM diagnostics into the clients of LTO.
Add a hook in the C API of LTO so that clients of the code generator can set
their own handler for the LLVM diagnostics.
The handler is defined like this:
typedef void (*lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t
severity, const char *diag, void *ctxt)
- severity says how bad this is.
- diag is a string that contains the diagnostic message.
- ctxt is the registered context for this handler.

This hook is more general than the lto_get_error_message, since this function
keeps only the latest message and can only be queried when something went wrong
(no warning for instance).

<rdar://problem/15517596>

llvm-svn: 199338
2014-01-15 22:04:35 +00:00
Duncan P. N. Exon Smith 93be7c4fb3 Reapply "LTO: add API to set strategy for -internalize"
Reapply r199191, reverted in r199197 because it carelessly broke
Other/link-opts.ll.  The problem was that calling
createInternalizePass("main") would select
createInternalizePass(bool("main")) instead of
createInternalizePass(ArrayRef<const char *>("main")).  This commit
fixes the bug.

The original commit message follows.

Add API to LTOCodeGenerator to specify a strategy for the -internalize
pass.

This is a new attempt at Bill's change in r185882, which he reverted in
r188029 due to problems with the gold linker.  This puts the onus on the
linker to decide whether (and what) to internalize.

In particular, running internalize before outputting an object file may
change a 'weak' symbol into an internal one, even though that symbol
could be needed by an external object file --- e.g., with arclite.

This patch enables three strategies:

- LTO_INTERNALIZE_FULL: the default (and the old behaviour).
- LTO_INTERNALIZE_NONE: skip -internalize.
- LTO_INTERNALIZE_HIDDEN: only -internalize symbols with hidden
  visibility.

LTO_INTERNALIZE_FULL should be used when linking an executable.

Outputting an object file (e.g., via ld -r) is more complicated, and
depends on whether hidden symbols should be internalized.  E.g., for
ld -r, LTO_INTERNALIZE_NONE can be used when -keep_private_externs, and
LTO_INTERNALIZE_HIDDEN can be used otherwise.  However,
LTO_INTERNALIZE_FULL is inappropriate, since the output object file will
eventually need to link with others.

lto_codegen_set_internalize_strategy() sets the strategy for subsequent
calls to lto_codegen_write_merged_modules() and lto_codegen_compile*().

<rdar://problem/14334895>

llvm-svn: 199244
2014-01-14 18:52:17 +00:00
NAKAMURA Takumi 23c0ab53b2 Revert r199191, "LTO: add API to set strategy for -internalize"
Please update also Other/link-opts.ll, in next time.

llvm-svn: 199197
2014-01-14 09:40:18 +00:00
Duncan P. N. Exon Smith 43ea3478bf LTO: add API to set strategy for -internalize
Add API to LTOCodeGenerator to specify a strategy for the -internalize
pass.

This is a new attempt at Bill's change in r185882, which he reverted in
r188029 due to problems with the gold linker.  This puts the onus on the
linker to decide whether (and what) to internalize.

In particular, running internalize before outputting an object file may
change a 'weak' symbol into an internal one, even though that symbol
could be needed by an external object file --- e.g., with arclite.

This patch enables three strategies:

- LTO_INTERNALIZE_FULL: the default (and the old behaviour).
- LTO_INTERNALIZE_NONE: skip -internalize.
- LTO_INTERNALIZE_HIDDEN: only -internalize symbols with hidden
  visibility.

LTO_INTERNALIZE_FULL should be used when linking an executable.

Outputting an object file (e.g., via ld -r) is more complicated, and
depends on whether hidden symbols should be internalized.  E.g., for
ld -r, LTO_INTERNALIZE_NONE can be used when -keep_private_externs, and
LTO_INTERNALIZE_HIDDEN can be used otherwise.  However,
LTO_INTERNALIZE_FULL is inappropriate, since the output object file will
eventually need to link with others.

lto_codegen_set_internalize_strategy() sets the strategy for subsequent
calls to lto_codegen_write_merged_modules() and lto_codegen_compile*().

<rdar://problem/14334895>

llvm-svn: 199191
2014-01-14 06:37:26 +00:00
Chandler Carruth 07baed53e8 Re-sort #include lines again, prior to moving headers around.
llvm-svn: 199080
2014-01-13 08:04:33 +00:00
Nico Weber c27118ddb6 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
Nico Weber 47ba8fa7ec Strip dead code when linking by default with BFD ld (linux, ...) and ld64 (os x).
This reduces the size of clang-format from 22 MB to 1.8 MB, diagtool goes from
21 MB to 2.8 MB, libclang.so goes from 29 MB to 20 MB, etc.  The size of the
bin/ folder shrinks from 270 MB to 200 MB.

Targets that support plugins and don't already use EXPORTED_SYMBOL_FILE
(which libclang and libLTO already do) can set NO_DEAD_STRIP to opt out.

llvm-svn: 198087
2013-12-27 22:38:59 +00:00
NAKAMURA Takumi 17b23098ee [CMake] Add MCDisassembler to tools/lto. (has been removed since r196908)
lto.exports really exports LLVM-C Disasm stuff.

llvm-svn: 196911
2013-12-10 11:50:34 +00:00
NAKAMURA Takumi b5c4b87690 [CMake] Update LLVM_LINK_COMPONENTS for each CMakeLists.txt.
llvm-svn: 196908
2013-12-10 11:13:32 +00:00
Bob Wilson ed1b2e5d98 Change libLTO back to linking with @executable_path instead of @rpath.
This partially reverts r187641 until ld64 adopts a change to link with an
rpath setting.

llvm-svn: 194418
2013-11-11 20:08:24 +00:00
Rafael Espindola 282a47037b 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
Reid Kleckner ddac15108a lto.h: Use lto_bool_t instead of int to restore the ABI
This reverts commit r193255 and instead creates an lto_bool_t typedef
that points to bool, _Bool, or unsigned char depending on what is
available.  Only recent versions of MSVC provide a stdbool.h header.

Reviewers: rafael.espindola

Differential Revision: http://llvm-reviews.chandlerc.com/D2019

llvm-svn: 193377
2013-10-24 22:26:04 +00:00
NAKAMURA Takumi b13d51c6eb llvm-c/lto.h: Avoid use of bool.
llvm-svn: 193255
2013-10-23 17:56:46 +00:00
Rafael Espindola 3f359430b3 Only modify lto.exports.def when contents have changed.
Patch by Greg Bedwell.

llvm-svn: 192182
2013-10-08 15:07:00 +00:00
Rafael Espindola 1c26db861b Add lto_codegen_add_dso_symbol to the export list.
llvm-svn: 191970
2013-10-04 17:30:14 +00:00
Rafael Espindola cda2911caa 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 efa02d53ff Fix option parsing in the gold plugin.
This was broken when options were moved up in r191680. No test because this is
specific LLVMgold.so/libLTO.so.

Patch by Tom Roeder!

llvm-svn: 191829
2013-10-02 14:36:23 +00:00
Rafael Espindola d38f9af213 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!

llvm-svn: 191823
2013-10-02 14:04:38 +00:00
Rafael Espindola 0b385c77f7 Move command line options to the users of libLTO. Fixes --enable-shared build.
Patch by Richard Sandiford.

llvm-svn: 191680
2013-09-30 16:39:19 +00:00
Rafael Espindola cbef8e60e3 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

llvm-svn: 191679
2013-09-30 16:32:51 +00:00
Rafael Espindola e693181c10 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!

llvm-svn: 191670
2013-09-30 15:28:14 +00:00
Peter Collingbourne 4ccf0f1bef Move LTO support library to a component, allowing it to be tested
more reliably across platforms.  Patch by Tom Roeder!

llvm-svn: 191343
2013-09-24 23:52:22 +00:00
Peter Collingbourne 4e380b0a04 Fix LTO handling of module-level assembly (PR14152).
Patch by Tom Roeder!

llvm-svn: 191042
2013-09-19 22:15:52 +00:00
Joey Gouly db6144e3e3 [LTO] Fix the LTO tool, after my API breakage.
Thanks to Zonr Chang!

llvm-svn: 190602
2013-09-12 12:55:29 +00:00
Rafael Espindola b7c0b4a327 Rename some variables to match the style guide.
I am about to patch this code, and this makes the diff far more readable.

llvm-svn: 189982
2013-09-04 20:08:46 +00:00
Rafael Espindola c80c969e6f Rename variables to match the style guide and clang-format.
llvm-svn: 189962
2013-09-04 17:44:24 +00:00