summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm-c
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
commit43ea3478bf64e7ebfb588a1a66fbcc2161e768bb (patch)
tree7defe0d1715be7fa636916ad47d3cad6ea63a7ff /llvm/include/llvm-c
parent1de36917d304f40af314fa0c6048eb0fd7c2740e (diff)
downloadbcm5719-llvm-43ea3478bf64e7ebfb588a1a66fbcc2161e768bb.tar.gz
bcm5719-llvm-43ea3478bf64e7ebfb588a1a66fbcc2161e768bb.zip
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
Diffstat (limited to 'llvm/include/llvm-c')
-rw-r--r--llvm/include/llvm-c/lto.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index 89f54b7a7b7..2292f470eba 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -40,7 +40,7 @@ typedef bool lto_bool_t;
* @{
*/
-#define LTO_API_VERSION 5
+#define LTO_API_VERSION 6
typedef enum {
LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */
@@ -73,6 +73,11 @@ typedef enum {
LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2
} lto_codegen_model;
+typedef enum {
+ LTO_INTERNALIZE_FULL = 0,
+ LTO_INTERNALIZE_NONE = 1,
+ LTO_INTERNALIZE_HIDDEN = 2
+} lto_internalize_strategy;
/** opaque reference to a loaded object module */
typedef struct LTOModule* lto_module_t;
@@ -264,6 +269,14 @@ lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
int nargs);
/**
+ * Sets the strategy to use during internalize. Default strategy is
+ * LTO_INTERNALIZE_FULL.
+ */
+extern void
+lto_codegen_set_internalize_strategy(lto_code_gen_t cg,
+ lto_internalize_strategy);
+
+/**
* Tells LTO optimization passes that this symbol must be preserved
* because it is referenced by native code or a command line option.
*/
OpenPOWER on IntegriCloud