diff options
| author | 2012-04-20 14:27:29 -0700 | |
|---|---|---|
| committer | 2012-04-20 14:27:29 -0700 | |
| commit | dbd0034c50362cc1dd8eee144e78e183cc49eaf7 (patch) | |
| tree | da904c59c513fa864aff0ef4dccaf4d712caf99c /src/compiler_llvm | |
| parent | f1cb9a546bf0e6e46c876d76c3dbf6da3634b1f0 (diff) | |
Specify the filename upon writing.
Change-Id: I5aac9401ab03cc5fa3a6573ef9c9dbdda9163149
Diffstat (limited to 'src/compiler_llvm')
| -rw-r--r-- | src/compiler_llvm/compilation_unit.cc | 4 | ||||
| -rw-r--r-- | src/compiler_llvm/compilation_unit.h | 11 | ||||
| -rw-r--r-- | src/compiler_llvm/compiler_llvm.cc | 11 |
3 files changed, 6 insertions, 20 deletions
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc index 66fdba06c6..4eb7fb53cb 100644 --- a/src/compiler_llvm/compilation_unit.cc +++ b/src/compiler_llvm/compilation_unit.cc @@ -137,11 +137,11 @@ CompilationUnit::~CompilationUnit() { } -bool CompilationUnit::WriteBitcodeToFile() { +bool CompilationUnit::WriteBitcodeToFile(const std::string& bitcode_filename) { std::string errmsg; llvm::OwningPtr<llvm::tool_output_file> out_file( - new llvm::tool_output_file(bitcode_filename_.c_str(), errmsg, + new llvm::tool_output_file(bitcode_filename.c_str(), errmsg, llvm::raw_fd_ostream::F_Binary)); diff --git a/src/compiler_llvm/compilation_unit.h b/src/compiler_llvm/compilation_unit.h index 953f4f46af..b206c8035f 100644 --- a/src/compiler_llvm/compilation_unit.h +++ b/src/compiler_llvm/compilation_unit.h @@ -69,14 +69,6 @@ class CompilationUnit { return irb_.get(); } - std::string const& GetBitcodeFileName() const { - return bitcode_filename_; - } - - void SetBitcodeFileName(std::string const& filename) { - bitcode_filename_ = filename; - } - ElfImage GetElfImage() const { return ElfImage(elf_image_); } @@ -86,7 +78,7 @@ class CompilationUnit { return num_elf_funcs_++; } - bool WriteBitcodeToFile(); + bool WriteBitcodeToFile(const std::string& bitcode_filename); bool Materialize(); @@ -116,7 +108,6 @@ class CompilationUnit { llvm::Module* module_; std::string elf_image_; - std::string bitcode_filename_; SafeMap<const llvm::Function*, CompiledMethod*> compiled_methods_map_; diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc index 894521033d..28320c74c6 100644 --- a/src/compiler_llvm/compiler_llvm.cc +++ b/src/compiler_llvm/compiler_llvm.cc @@ -129,15 +129,8 @@ void CompilerLLVM::EnsureCompilationUnit() { // Allocate compilation unit size_t cunit_idx = cunits_.size(); - curr_cunit_ = new CompilationUnit(insn_set_, cunit_idx); - // Setup bitcode output filename - if (IsBitcodeFileNameAvailable()) { - curr_cunit_->SetBitcodeFileName( - StringPrintf("%s-%zu", bitcode_filename_.c_str(), cunit_idx)); - } - // Register compilation unit cunits_.push_back(curr_cunit_); } @@ -167,7 +160,9 @@ void CompilerLLVM::Materialize() { // Write bitcode to file when filename is set if (IsBitcodeFileNameAvailable()) { - curr_cunit_->WriteBitcodeToFile(); + const size_t cunit_idx = cunits_.size(); + curr_cunit_->WriteBitcodeToFile( + StringPrintf("%s-%zu", bitcode_filename_.c_str(), cunit_idx)); } // Materialize the llvm::Module into ELF object file |