diff options
| author | 2012-04-17 16:42:19 -0700 | |
|---|---|---|
| committer | 2012-04-17 16:42:19 -0700 | |
| commit | 1776572d3c47d8de66e211144a52cbc129a81d69 (patch) | |
| tree | 79078b521d56019ec281c906aa0db79d3cfbaca0 /src/compiler_llvm/compilation_unit.cc | |
| parent | 83bb6624fe370e7f8922471598adcd1f936e4b1a (diff) | |
Fix stack overflow errors.
Change-Id: Ibc4e1fc4ec6b9c44e8b7a07316b54092f5cc4aea
Diffstat (limited to 'src/compiler_llvm/compilation_unit.cc')
| -rw-r--r-- | src/compiler_llvm/compilation_unit.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc index 32f17869cb..b976fd2b0f 100644 --- a/src/compiler_llvm/compilation_unit.cc +++ b/src/compiler_llvm/compilation_unit.cc @@ -204,7 +204,7 @@ bool CompilationUnit::Materialize() { llvm::TargetMachine* target_machine = target->createTargetMachine(target_triple, "", target_attr, target_options, llvm::Reloc::Static, llvm::CodeModel::Small, - llvm::CodeGenOpt::None); + llvm::CodeGenOpt::Less); CHECK(target_machine != NULL) << "Failed to create target machine"; @@ -220,6 +220,14 @@ bool CompilationUnit::Materialize() { llvm::FunctionPassManager fpm(module_); fpm.add(new llvm::TargetData(*target_data)); + // Add optimization pass + llvm::PassManagerBuilder pm_builder; + pm_builder.Inliner = NULL; // TODO: add some inline in the future + pm_builder.OptLevel = 1; + pm_builder.DisableSimplifyLibCalls = 1; + pm_builder.populateModulePassManager(pm); + pm_builder.populateFunctionPassManager(fpm); + // Add passes to emit ELF image { llvm::formatted_raw_ostream formatted_os( @@ -237,6 +245,14 @@ bool CompilationUnit::Materialize() { // Add pass to update the frame_size_in_bytes_ pm.add(new ::UpdateFrameSizePass(this)); + // Run the per-function optimization + fpm.doInitialization(); + for (llvm::Module::iterator F = module_->begin(), E = module_->end(); + F != E; ++F) { + fpm.run(*F); + } + fpm.doFinalization(); + // Run the code generation passes pm.run(*module_); } |