Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 1 | //===-lto.cpp - LLVM Link Time Optimizer ----------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 7 | // |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 10 | // This file implements the Link Time Optimization library. This library is |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 11 | // intended to be used by linker to optimize code at link time. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm-c/lto.h" |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 16 | #include "llvm/CodeGen/CommandFlags.h" |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 17 | #include "llvm/LTO/LTOCodeGenerator.h" |
| 18 | #include "llvm/LTO/LTOModule.h" |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 19 | #include "llvm-c/Core.h" |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 20 | #include "llvm-c/Target.h" |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 21 | |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 22 | // extra command-line flags needed for LTOCodeGenerator |
| 23 | static cl::opt<bool> |
| 24 | DisableOpt("disable-opt", cl::init(false), |
| 25 | cl::desc("Do not run any optimization passes")); |
| 26 | |
| 27 | static cl::opt<bool> |
| 28 | DisableInline("disable-inlining", cl::init(false), |
| 29 | cl::desc("Do not run the inliner pass")); |
| 30 | |
| 31 | static cl::opt<bool> |
| 32 | DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false), |
| 33 | cl::desc("Do not run the GVN load PRE pass")); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 34 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 35 | // Holds most recent error string. |
| 36 | // *** Not thread safe *** |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 37 | static std::string sLastErrorString; |
| 38 | |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 39 | // Holds the initialization state of the LTO module. |
| 40 | // *** Not thread safe *** |
| 41 | static bool initialized = false; |
| 42 | |
| 43 | // Initialize the configured targets if they have not been initialized. |
| 44 | static void lto_initialize() { |
| 45 | if (!initialized) { |
| 46 | LLVMInitializeAllTargetInfos(); |
| 47 | LLVMInitializeAllTargets(); |
| 48 | LLVMInitializeAllTargetMCs(); |
| 49 | LLVMInitializeAllAsmParsers(); |
| 50 | LLVMInitializeAllAsmPrinters(); |
| 51 | LLVMInitializeAllDisassemblers(); |
| 52 | initialized = true; |
| 53 | } |
| 54 | } |
| 55 | |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 56 | static void lto_set_target_options(llvm::TargetOptions &Options) { |
| 57 | Options.LessPreciseFPMADOption = EnableFPMAD; |
| 58 | Options.NoFramePointerElim = DisableFPElim; |
| 59 | Options.AllowFPOpFusion = FuseFPOps; |
| 60 | Options.UnsafeFPMath = EnableUnsafeFPMath; |
| 61 | Options.NoInfsFPMath = EnableNoInfsFPMath; |
| 62 | Options.NoNaNsFPMath = EnableNoNaNsFPMath; |
| 63 | Options.HonorSignDependentRoundingFPMathOption = |
| 64 | EnableHonorSignDependentRoundingFPMath; |
| 65 | Options.UseSoftFloat = GenerateSoftFloatCalls; |
| 66 | if (FloatABIForCalls != llvm::FloatABI::Default) |
| 67 | Options.FloatABIType = FloatABIForCalls; |
| 68 | Options.NoZerosInBSS = DontPlaceZerosInBSS; |
| 69 | Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt; |
| 70 | Options.DisableTailCalls = DisableTailCalls; |
| 71 | Options.StackAlignmentOverride = OverrideStackAlignment; |
| 72 | Options.TrapFuncName = TrapFuncName; |
| 73 | Options.PositionIndependentExecutable = EnablePIE; |
| 74 | Options.EnableSegmentedStacks = SegmentedStacks; |
| 75 | Options.UseInitArray = UseInitArray; |
| 76 | } |
| 77 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 78 | /// lto_get_version - Returns a printable string. |
| 79 | extern const char* lto_get_version() { |
| 80 | return LTOCodeGenerator::getVersionString(); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 83 | /// lto_get_error_message - Returns the last error string or NULL if last |
| 84 | /// operation was successful. |
| 85 | const char* lto_get_error_message() { |
| 86 | return sLastErrorString.c_str(); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 87 | } |
| 88 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 89 | /// lto_module_is_object_file - Validates if a file is a loadable object file. |
| 90 | bool lto_module_is_object_file(const char* path) { |
| 91 | return LTOModule::isBitcodeFile(path); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 94 | /// lto_module_is_object_file_for_target - Validates if a file is a loadable |
| 95 | /// object file compilable for requested target. |
| 96 | bool lto_module_is_object_file_for_target(const char* path, |
| 97 | const char* target_triplet_prefix) { |
| 98 | return LTOModule::isBitcodeFileForTarget(path, target_triplet_prefix); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 101 | /// lto_module_is_object_file_in_memory - Validates if a buffer is a loadable |
| 102 | /// object file. |
| 103 | bool lto_module_is_object_file_in_memory(const void* mem, size_t length) { |
| 104 | return LTOModule::isBitcodeFile(mem, length); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 107 | /// lto_module_is_object_file_in_memory_for_target - Validates if a buffer is a |
| 108 | /// loadable object file compilable for the target. |
| 109 | bool |
| 110 | lto_module_is_object_file_in_memory_for_target(const void* mem, |
| 111 | size_t length, |
| 112 | const char* target_triplet_prefix) { |
| 113 | return LTOModule::isBitcodeFileForTarget(mem, length, target_triplet_prefix); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 116 | /// lto_module_create - Loads an object file from disk. Returns NULL on error |
| 117 | /// (check lto_get_error_message() for details). |
| 118 | lto_module_t lto_module_create(const char* path) { |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 119 | lto_initialize(); |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 120 | llvm::TargetOptions Options; |
| 121 | lto_set_target_options(Options); |
| 122 | return LTOModule::makeLTOModule(path, Options, sLastErrorString); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 125 | /// lto_module_create_from_fd - Loads an object file from disk. Returns NULL on |
| 126 | /// error (check lto_get_error_message() for details). |
| 127 | lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) { |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 128 | lto_initialize(); |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 129 | llvm::TargetOptions Options; |
| 130 | lto_set_target_options(Options); |
| 131 | return LTOModule::makeLTOModule(fd, path, size, Options, sLastErrorString); |
Rafael Espindola | 56e41f7 | 2011-02-08 22:40:47 +0000 | [diff] [blame] | 132 | } |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 133 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 134 | /// lto_module_create_from_fd_at_offset - Loads an object file from disk. |
| 135 | /// Returns NULL on error (check lto_get_error_message() for details). |
Rafael Espindola | b39c7c7 | 2011-03-17 00:36:11 +0000 | [diff] [blame] | 136 | lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path, |
| 137 | size_t file_size, |
| 138 | size_t map_size, |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 139 | off_t offset) { |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 140 | lto_initialize(); |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 141 | llvm::TargetOptions Options; |
| 142 | lto_set_target_options(Options); |
| 143 | return LTOModule::makeLTOModule(fd, path, map_size, offset, Options, |
| 144 | sLastErrorString); |
Rafael Espindola | b39c7c7 | 2011-03-17 00:36:11 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 147 | /// lto_module_create_from_memory - Loads an object file from memory. Returns |
| 148 | /// NULL on error (check lto_get_error_message() for details). |
| 149 | lto_module_t lto_module_create_from_memory(const void* mem, size_t length) { |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 150 | lto_initialize(); |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 151 | llvm::TargetOptions Options; |
| 152 | lto_set_target_options(Options); |
| 153 | return LTOModule::makeLTOModule(mem, length, Options, sLastErrorString); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 156 | /// lto_module_dispose - Frees all memory for a module. Upon return the |
| 157 | /// lto_module_t is no longer valid. |
| 158 | void lto_module_dispose(lto_module_t mod) { |
| 159 | delete mod; |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 160 | } |
| 161 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 162 | /// lto_module_get_target_triple - Returns triplet string which the object |
| 163 | /// module was compiled under. |
| 164 | const char* lto_module_get_target_triple(lto_module_t mod) { |
| 165 | return mod->getTargetTriple(); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 168 | /// lto_module_set_target_triple - Sets triple string with which the object will |
| 169 | /// be codegened. |
| 170 | void lto_module_set_target_triple(lto_module_t mod, const char *triple) { |
| 171 | return mod->setTargetTriple(triple); |
Rafael Espindola | 4ef89f5 | 2010-08-09 21:09:46 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 174 | /// lto_module_get_num_symbols - Returns the number of symbols in the object |
| 175 | /// module. |
| 176 | unsigned int lto_module_get_num_symbols(lto_module_t mod) { |
| 177 | return mod->getSymbolCount(); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 180 | /// lto_module_get_symbol_name - Returns the name of the ith symbol in the |
| 181 | /// object module. |
| 182 | const char* lto_module_get_symbol_name(lto_module_t mod, unsigned int index) { |
| 183 | return mod->getSymbolName(index); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 184 | } |
| 185 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 186 | /// lto_module_get_symbol_attribute - Returns the attributes of the ith symbol |
| 187 | /// in the object module. |
| 188 | lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod, |
| 189 | unsigned int index) { |
| 190 | return mod->getSymbolAttributes(index); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 193 | /// lto_codegen_create - Instantiates a code generator. Returns NULL if there |
| 194 | /// is an error. |
| 195 | lto_code_gen_t lto_codegen_create(void) { |
Peter Collingbourne | 4ccf0f1 | 2013-09-24 23:52:22 +0000 | [diff] [blame] | 196 | lto_initialize(); |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 197 | |
| 198 | TargetOptions Options; |
| 199 | lto_set_target_options(Options); |
| 200 | |
| 201 | LTOCodeGenerator *CodeGen = new LTOCodeGenerator(); |
| 202 | if (CodeGen) |
| 203 | CodeGen->setTargetOptions(Options); |
| 204 | return CodeGen; |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 205 | } |
| 206 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 207 | /// lto_codegen_dispose - Frees all memory for a code generator. Upon return the |
| 208 | /// lto_code_gen_t is no longer valid. |
| 209 | void lto_codegen_dispose(lto_code_gen_t cg) { |
| 210 | delete cg; |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 213 | /// lto_codegen_add_module - Add an object module to the set of modules for |
| 214 | /// which code will be generated. Returns true on error (check |
| 215 | /// lto_get_error_message() for details). |
| 216 | bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) { |
Shuxin Yang | b6696a9 | 2013-08-07 05:19:23 +0000 | [diff] [blame] | 217 | return !cg->addModule(mod, sLastErrorString); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 220 | /// lto_codegen_set_debug_model - Sets what if any format of debug info should |
| 221 | /// be generated. Returns true on error (check lto_get_error_message() for |
| 222 | /// details). |
| 223 | bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) { |
Shuxin Yang | b6696a9 | 2013-08-07 05:19:23 +0000 | [diff] [blame] | 224 | cg->setDebugInfo(debug); |
| 225 | return false; |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 226 | } |
| 227 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 228 | /// lto_codegen_set_pic_model - Sets what code model to generated. Returns true |
| 229 | /// on error (check lto_get_error_message() for details). |
| 230 | bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) { |
Shuxin Yang | b6696a9 | 2013-08-07 05:19:23 +0000 | [diff] [blame] | 231 | cg->setCodePICModel(model); |
| 232 | return false; |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 235 | /// lto_codegen_set_cpu - Sets the cpu to generate code for. |
Bill Wendling | 152e473 | 2012-03-31 10:44:20 +0000 | [diff] [blame] | 236 | void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) { |
Rafael Espindola | ccab1dd | 2010-08-11 00:15:13 +0000 | [diff] [blame] | 237 | return cg->setCpu(cpu); |
| 238 | } |
| 239 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 240 | /// lto_codegen_set_assembler_path - Sets the path to the assembler tool. |
| 241 | void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path) { |
Rafael Espindola | fac373c | 2011-02-24 21:04:06 +0000 | [diff] [blame] | 242 | // In here only for backwards compatibility. We use MC now. |
Nick Kledzik | cac8c8a | 2009-06-04 00:28:45 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 245 | /// lto_codegen_set_assembler_args - Sets extra arguments that libLTO should |
| 246 | /// pass to the assembler. |
Bill Wendling | 152e473 | 2012-03-31 10:44:20 +0000 | [diff] [blame] | 247 | void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 248 | int nargs) { |
Rafael Espindola | fac373c | 2011-02-24 21:04:06 +0000 | [diff] [blame] | 249 | // In here only for backwards compatibility. We use MC now. |
Rafael Espindola | 0045646 | 2010-08-10 18:55:09 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 252 | /// lto_codegen_add_must_preserve_symbol - Adds to a list of all global symbols |
| 253 | /// that must exist in the final generated code. If a function is not listed |
| 254 | /// there, it might be inlined into every usage and optimized away. |
| 255 | void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, |
Bill Wendling | 152e473 | 2012-03-31 10:44:20 +0000 | [diff] [blame] | 256 | const char *symbol) { |
Evan Cheng | d646096 | 2009-06-26 06:57:16 +0000 | [diff] [blame] | 257 | cg->addMustPreserveSymbol(symbol); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 258 | } |
| 259 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 260 | /// lto_codegen_write_merged_modules - Writes a new file at the specified path |
| 261 | /// that contains the merged contents of all modules added so far. Returns true |
| 262 | /// on error (check lto_get_error_message() for details). |
Bill Wendling | 152e473 | 2012-03-31 10:44:20 +0000 | [diff] [blame] | 263 | bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) { |
Shuxin Yang | b6696a9 | 2013-08-07 05:19:23 +0000 | [diff] [blame] | 264 | return !cg->writeMergedModules(path, sLastErrorString); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 267 | /// lto_codegen_compile - Generates code for all added modules into one native |
| 268 | /// object file. On success returns a pointer to a generated mach-o/ELF buffer |
| 269 | /// and length set to the buffer size. The buffer is owned by the lto_code_gen_t |
| 270 | /// object and will be freed when lto_codegen_dispose() is called, or |
| 271 | /// lto_codegen_compile() is called again. On failure, returns NULL (check |
| 272 | /// lto_get_error_message() for details). |
Bill Wendling | 152e473 | 2012-03-31 10:44:20 +0000 | [diff] [blame] | 273 | const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) { |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 274 | return cg->compile(length, DisableOpt, DisableInline, DisableGVNLoadPRE, |
| 275 | sLastErrorString); |
Nick Kledzik | 07b4a62 | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Bill Wendling | 152e473 | 2012-03-31 10:44:20 +0000 | [diff] [blame] | 278 | /// lto_codegen_compile_to_file - Generates code for all added modules into one |
| 279 | /// native object file. The name of the file is written to name. Returns true on |
| 280 | /// error. |
| 281 | bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) { |
Rafael Espindola | 0b385c7 | 2013-09-30 16:39:19 +0000 | [diff] [blame^] | 282 | return !cg->compile_to_file(name, DisableOpt, DisableInline, DisableGVNLoadPRE, |
| 283 | sLastErrorString); |
Rafael Espindola | 26b57ff | 2011-03-22 20:57:13 +0000 | [diff] [blame] | 284 | } |
| 285 | |
Bill Wendling | 36cbf03 | 2012-03-30 10:29:38 +0000 | [diff] [blame] | 286 | /// lto_codegen_debug_options - Used to pass extra options to the code |
| 287 | /// generator. |
Bill Wendling | 152e473 | 2012-03-31 10:44:20 +0000 | [diff] [blame] | 288 | void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) { |
Devang Patel | a0e4fb8 | 2008-07-03 22:53:14 +0000 | [diff] [blame] | 289 | cg->setCodeGenDebugOptions(opt); |
Duncan Sands | 31554ab | 2009-07-03 15:38:01 +0000 | [diff] [blame] | 290 | } |