summaryrefslogtreecommitdiff
path: root/tools/lto
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-01-14 06:37:26 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-01-14 06:37:26 +0000
commit67af0456bc713b1f27e7b38bae1bf707172b8cdf (patch)
treee4f5f353ef0ac2d9878982acd7635d109c6920e6 /tools/lto
parent5b8e04cd718a1b75bf129a6226c3d7212f29ab96 (diff)
downloadllvm-67af0456bc713b1f27e7b38bae1bf707172b8cdf.tar.gz
llvm-67af0456bc713b1f27e7b38bae1bf707172b8cdf.tar.bz2
llvm-67af0456bc713b1f27e7b38bae1bf707172b8cdf.tar.xz
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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199191 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/lto.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index 59b778dcc9..a28257f6ab 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -252,6 +252,13 @@ void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
// In here only for backwards compatibility. We use MC now.
}
+/// lto_codegen_set_internalize_strategy - Sets the strategy to use during
+/// internalize.
+void lto_codegen_set_internalize_strategy(lto_code_gen_t cg,
+ lto_internalize_strategy strategy) {
+ cg->setInternalizeStrategy(strategy);
+}
+
/// lto_codegen_add_must_preserve_symbol - Adds to a list of all global symbols
/// that must exist in the final generated code. If a function is not listed
/// there, it might be inlined into every usage and optimized away.