llvm.org GIT mirror llvm / 920ae98
fix dangling pointer and argv off by one errors. Add support for --disable-inlining git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53249 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Kledzik 11 years ago
3 changed file(s) with 27 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
2222 #include "llvm/DerivedTypes.h"
2323 #include "llvm/ModuleProvider.h"
2424 #include "llvm/Bitcode/ReaderWriter.h"
25 #include "llvm/Support/CommandLine.h"
2526 #include "llvm/Support/SystemUtils.h"
2627 #include "llvm/Support/Mangler.h"
2728 #include "llvm/Support/MemoryBuffer.h"
5152
5253 using namespace llvm;
5354
55 static cl::opt DisableInline("disable-inlining",
56 cl::desc("Do not run the inliner pass"));
5457
5558
5659 const char* LTOCodeGenerator::getVersionString()
333336 break;
334337 }
335338
336 for (unsigned opt_index = 0, opt_size = _codegenOptions.size();
337 opt_index < opt_size; ++opt_index) {
338 std::vector cgOpts;
339 std::string &optString = _codegenOptions[opt_index];
340 for (std::string Opt = getToken(optString);
341 !Opt.empty(); Opt = getToken(optString))
342 cgOpts.push_back(Opt.c_str());
343
344 int pseudo_argc = cgOpts.size()-1;
345 cl::ParseCommandLineOptions(pseudo_argc, (char**)&cgOpts[0]);
346 }
339 // if options were requested, set them
340 if ( !_codegenOptions.empty() )
341 cl::ParseCommandLineOptions(_codegenOptions.size(),
342 (char**)&_codegenOptions[0]);
347343
348344 // Instantiate the pass manager to organize the passes.
349345 PassManager passes;
374370 // function pointers. When this happens, we often have to resolve varargs
375371 // calls, etc, so let instcombine do this.
376372 passes.add(createInstructionCombiningPass());
377 passes.add(createFunctionInliningPass()); // Inline small functions
373 if (!DisableInline)
374 passes.add(createFunctionInliningPass()); // Inline small functions
378375 passes.add(createPruneEHPass()); // Remove dead EH info
379376 passes.add(createGlobalDCEPass()); // Remove dead functions
380377
453450 }
454451
455452
456
453 /// Optimize merged modules using various IPO passes
454 void LTOCodeGenerator::setCodeGenDebugOptions(const char* options)
455 {
456 std::string ops(options);
457 for (std::string o = getToken(ops); !o.empty(); o = getToken(ops)) {
458 // ParseCommandLineOptions() expects argv[0] to be program name.
459 // Lazily add that.
460 if ( _codegenOptions.empty() )
461 _codegenOptions.push_back("libLTO");
462 _codegenOptions.push_back(strdup(o.c_str()));
463 }
464 }
3838 bool writeMergedModules(const char* path,
3939 std::string& errMsg);
4040 const void* compile(size_t* length, std::string& errMsg);
41 void setCodeGenDebugOptions(const char *opts) {
42 _codegenOptions.push_back(std::string(opts));
43 }
41 void setCodeGenDebugOptions(const char *opts);
4442 private:
4543 bool generateAssemblyCode(std::ostream& out,
4644 std::string& errMsg);
5856 lto_codegen_model _codeModel;
5957 StringSet _mustPreserveSymbols;
6058 llvm::MemoryBuffer* _nativeObjectFile;
61 llvm::SmallVector _codegenOptions;
59 std::vector _codegenOptions;
6260 };
6361
6462 #endif // LTO_CODE_GENERATOR_H
236236 return cg->compile(length, sLastErrorString);
237237 }
238238
239
240 //
241 // Used to pass extra options to the code generator
242 //
239243 extern void
240244 lto_codegen_debug_options(lto_code_gen_t cg, const char * opt)
241245 {