Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "compilation_unit.h" |
| 18 | |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 19 | #include "compiled_method.h" |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 20 | #include "file.h" |
Elliott Hughes | 0f3c553 | 2012-03-30 14:51:51 -0700 | [diff] [blame] | 21 | #include "instruction_set.h" |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 22 | #include "ir_builder.h" |
| 23 | #include "logging.h" |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 24 | #include "os.h" |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 25 | |
TDYa127 | d668a06 | 2012-04-13 12:36:57 -0700 | [diff] [blame] | 26 | #include "runtime_support_builder_arm.h" |
| 27 | #include "runtime_support_builder_x86.h" |
| 28 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 29 | #include <llvm/ADT/OwningPtr.h> |
| 30 | #include <llvm/ADT/StringSet.h> |
| 31 | #include <llvm/ADT/Triple.h> |
| 32 | #include <llvm/Analysis/CallGraph.h> |
| 33 | #include <llvm/Analysis/DebugInfo.h> |
| 34 | #include <llvm/Analysis/LoopPass.h> |
| 35 | #include <llvm/Analysis/RegionPass.h> |
| 36 | #include <llvm/Analysis/Verifier.h> |
| 37 | #include <llvm/Assembly/PrintModulePass.h> |
| 38 | #include <llvm/Bitcode/ReaderWriter.h> |
| 39 | #include <llvm/CallGraphSCCPass.h> |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 40 | #include <llvm/CodeGen/MachineFrameInfo.h> |
| 41 | #include <llvm/CodeGen/MachineFunction.h> |
| 42 | #include <llvm/CodeGen/MachineFunctionPass.h> |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 43 | #include <llvm/DerivedTypes.h> |
| 44 | #include <llvm/LLVMContext.h> |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 45 | #include <llvm/Module.h> |
| 46 | #include <llvm/PassManager.h> |
| 47 | #include <llvm/Support/Debug.h> |
| 48 | #include <llvm/Support/FormattedStream.h> |
| 49 | #include <llvm/Support/ManagedStatic.h> |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 50 | #include <llvm/Support/MemoryBuffer.h> |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 51 | #include <llvm/Support/PassNameParser.h> |
| 52 | #include <llvm/Support/PluginLoader.h> |
| 53 | #include <llvm/Support/PrettyStackTrace.h> |
| 54 | #include <llvm/Support/Signals.h> |
| 55 | #include <llvm/Support/SystemUtils.h> |
| 56 | #include <llvm/Support/TargetRegistry.h> |
| 57 | #include <llvm/Support/TargetSelect.h> |
| 58 | #include <llvm/Support/ToolOutputFile.h> |
| 59 | #include <llvm/Support/raw_ostream.h> |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 60 | #include <llvm/Support/system_error.h> |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 61 | #include <llvm/Target/TargetData.h> |
| 62 | #include <llvm/Target/TargetLibraryInfo.h> |
| 63 | #include <llvm/Target/TargetMachine.h> |
Shih-wei Liao | f1cb9a5 | 2012-04-20 01:49:18 -0700 | [diff] [blame] | 64 | #include <llvm/Transforms/IPO.h> |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 65 | #include <llvm/Transforms/IPO/PassManagerBuilder.h> |
| 66 | |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 67 | #include <sys/types.h> |
| 68 | #include <sys/wait.h> |
| 69 | #include <unistd.h> |
| 70 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 71 | #include <string> |
| 72 | |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 73 | namespace { |
| 74 | |
| 75 | class UpdateFrameSizePass : public llvm::MachineFunctionPass { |
| 76 | public: |
| 77 | static char ID; |
| 78 | |
| 79 | UpdateFrameSizePass() : llvm::MachineFunctionPass(ID), cunit_(NULL) { |
| 80 | LOG(FATAL) << "Unexpected instantiation of UpdateFrameSizePass"; |
| 81 | // NOTE: We have to declare this constructor for llvm::RegisterPass, but |
| 82 | // this constructor won't work because we have no information on |
| 83 | // CompilationUnit. Thus, we should place a LOG(FATAL) here. |
| 84 | } |
| 85 | |
| 86 | UpdateFrameSizePass(art::compiler_llvm::CompilationUnit* cunit) |
| 87 | : llvm::MachineFunctionPass(ID), cunit_(cunit) { |
| 88 | } |
| 89 | |
| 90 | virtual bool runOnMachineFunction(llvm::MachineFunction &MF) { |
| 91 | cunit_->UpdateFrameSizeInBytes(MF.getFunction(), |
| 92 | MF.getFrameInfo()->getStackSize()); |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | private: |
| 97 | art::compiler_llvm::CompilationUnit* cunit_; |
| 98 | }; |
| 99 | |
| 100 | char UpdateFrameSizePass::ID = 0; |
| 101 | |
| 102 | llvm::RegisterPass<UpdateFrameSizePass> reg_update_frame_size_pass_( |
| 103 | "update-frame-size", "Update frame size pass", false, false); |
| 104 | |
| 105 | } // end anonymous namespace |
| 106 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 107 | namespace art { |
| 108 | namespace compiler_llvm { |
| 109 | |
| 110 | llvm::Module* makeLLVMModuleContents(llvm::Module* module); |
| 111 | |
| 112 | |
Logan Chien | 6546ec5 | 2012-03-17 20:08:29 +0800 | [diff] [blame] | 113 | CompilationUnit::CompilationUnit(InstructionSet insn_set, size_t elf_idx) |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 114 | : cunit_lock_("compilation_unit_lock"), insn_set_(insn_set), elf_idx_(elf_idx), |
| 115 | context_(new llvm::LLVMContext()), mem_usage_(0), num_elf_funcs_(0) { |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 116 | |
| 117 | // Create the module and include the runtime function declaration |
| 118 | module_ = new llvm::Module("art", *context_); |
| 119 | makeLLVMModuleContents(module_); |
| 120 | |
| 121 | // Create IRBuilder |
| 122 | irb_.reset(new IRBuilder(*context_, *module_)); |
TDYa127 | d668a06 | 2012-04-13 12:36:57 -0700 | [diff] [blame] | 123 | |
| 124 | // We always need a switch case, so just use a normal function. |
| 125 | switch(insn_set_) { |
| 126 | default: |
| 127 | runtime_support_.reset(new RuntimeSupportBuilder(*context_, *module_, *irb_)); |
| 128 | break; |
| 129 | case kArm: |
| 130 | case kThumb2: |
| 131 | runtime_support_.reset(new RuntimeSupportBuilderARM(*context_, *module_, *irb_)); |
| 132 | break; |
| 133 | case kX86: |
| 134 | runtime_support_.reset(new RuntimeSupportBuilderX86(*context_, *module_, *irb_)); |
| 135 | break; |
| 136 | } |
| 137 | |
| 138 | runtime_support_->OptimizeRuntimeSupport(); |
| 139 | |
| 140 | irb_->SetRuntimeSupport(runtime_support_.get()); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | |
| 144 | CompilationUnit::~CompilationUnit() { |
| 145 | } |
| 146 | |
| 147 | |
Shih-wei Liao | dbd0034 | 2012-04-20 14:27:29 -0700 | [diff] [blame] | 148 | bool CompilationUnit::WriteBitcodeToFile(const std::string& bitcode_filename) { |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 149 | MutexLock GUARD(cunit_lock_); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 150 | std::string errmsg; |
| 151 | |
| 152 | llvm::OwningPtr<llvm::tool_output_file> out_file( |
Shih-wei Liao | dbd0034 | 2012-04-20 14:27:29 -0700 | [diff] [blame] | 153 | new llvm::tool_output_file(bitcode_filename.c_str(), errmsg, |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 154 | llvm::raw_fd_ostream::F_Binary)); |
| 155 | |
| 156 | |
| 157 | if (!errmsg.empty()) { |
| 158 | LOG(ERROR) << "Failed to create bitcode output file: " << errmsg; |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | llvm::WriteBitcodeToFile(module_, out_file->os()); |
| 163 | out_file->keep(); |
| 164 | |
| 165 | return true; |
| 166 | } |
| 167 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 168 | |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 169 | bool CompilationUnit::Materialize() { |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 170 | MutexLock GUARD(cunit_lock_); |
| 171 | |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 172 | // Prepare the pipe between parent process and child process |
| 173 | int pipe_fd[2]; |
| 174 | if (pipe(pipe_fd) == -1) { |
| 175 | LOG(FATAL) << "Failed to create pipe for CompilerWorker"; |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 176 | return false; |
| 177 | } |
Shih-wei Liao | 1776572 | 2012-04-17 16:42:19 -0700 | [diff] [blame] | 178 | |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 179 | // Fork a process to do the compilation |
| 180 | pid_t pid = fork(); |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 181 | if (pid < 0) { |
| 182 | close(pipe_fd[0]); |
| 183 | close(pipe_fd[1]); |
| 184 | PLOG(FATAL) << "Failed to fork a process to do the compilation"; |
| 185 | return false; |
| 186 | |
| 187 | } else if (pid == 0) { // Child process |
| 188 | // Close the unused pipe read end |
| 189 | close(pipe_fd[0]); |
| 190 | |
| 191 | // Change process groups, so we don't get ripped by ProcessManager |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 192 | setpgid(0, 0); |
Logan Chien | b9eaeea | 2012-03-17 19:45:01 +0800 | [diff] [blame] | 193 | |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 194 | // TODO: Should use exec* family instead of invoking a function. |
| 195 | // Forward our compilation request to bcc. |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 196 | exit(static_cast<int>(!MaterializeToFile(pipe_fd[1], insn_set_))); |
| 197 | |
| 198 | } else { // Parent process |
| 199 | // Close the unused pipe write end |
| 200 | close(pipe_fd[1]); |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 201 | |
| 202 | // Free the resources |
| 203 | context_.reset(NULL); |
| 204 | irb_.reset(NULL); |
| 205 | module_ = NULL; |
| 206 | |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 207 | // Read the result out from the pipe read end (until failure) |
| 208 | const size_t buf_size = 1024; |
| 209 | std::vector<uint8_t> buf(buf_size); |
| 210 | while (true) { |
| 211 | // Read from the pipe |
| 212 | ssize_t nread = read(pipe_fd[0], &*buf.begin(), buf_size); |
| 213 | if (nread < 0) { |
| 214 | if (errno == EAGAIN || errno == EINTR) { |
| 215 | continue; |
| 216 | } else { |
| 217 | LOG(ERROR) << "Unexpected error during IPC: " << strerror(errno); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // Append to the end of the elf_image_ |
| 222 | elf_image_.insert(elf_image_.end(), buf.begin(), buf.begin() + nread); |
| 223 | |
| 224 | if (nread < static_cast<ssize_t>(buf_size)) { // EOF reached! |
| 225 | break; |
| 226 | } |
| 227 | } |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 228 | |
| 229 | // Wait for child to finish |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 230 | int status; |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 231 | pid_t got_pid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); |
| 232 | if (got_pid != pid) { |
| 233 | PLOG(ERROR) << "waitpid failed: wanted " << pid << ", got " << got_pid; |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 234 | elf_image_.clear(); |
Logan Chien | b9eaeea | 2012-03-17 19:45:01 +0800 | [diff] [blame] | 235 | return false; |
| 236 | } |
| 237 | |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 238 | if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { |
| 239 | LOG(ERROR) << "Failed to compile the bitcode: " << WEXITSTATUS(status); |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 240 | elf_image_.clear(); |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 241 | return false; |
Shih-wei Liao | 1776572 | 2012-04-17 16:42:19 -0700 | [diff] [blame] | 242 | } |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 243 | |
| 244 | LOG(INFO) << "Compilation Unit: " << elf_idx_ << " (done)"; |
| 245 | return true; |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 246 | } |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 250 | void CompilationUnit::RegisterCompiledMethod(const llvm::Function* func, |
| 251 | CompiledMethod* compiled_method) { |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 252 | MutexLock GUARD(cunit_lock_); |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 253 | compiled_methods_map_.Put(func, compiled_method); |
| 254 | } |
| 255 | |
| 256 | |
| 257 | void CompilationUnit::UpdateFrameSizeInBytes(const llvm::Function* func, |
| 258 | size_t frame_size_in_bytes) { |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 259 | MutexLock GUARD(cunit_lock_); |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 260 | SafeMap<const llvm::Function*, CompiledMethod*>::iterator iter = |
| 261 | compiled_methods_map_.find(func); |
| 262 | |
| 263 | if (iter != compiled_methods_map_.end()) { |
| 264 | CompiledMethod* compiled_method = iter->second; |
| 265 | compiled_method->SetFrameSizeInBytes(frame_size_in_bytes); |
| 266 | |
| 267 | if (frame_size_in_bytes > 1728u) { |
| 268 | LOG(WARNING) << "Huge frame size: " << frame_size_in_bytes |
| 269 | << " elf_idx=" << compiled_method->GetElfIndex() |
| 270 | << " elf_func_idx=" << compiled_method->GetElfFuncIndex(); |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 275 | bool CompilationUnit::MaterializeToFile(int output_fd, |
| 276 | InstructionSet insn_set) { |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 277 | // Initialize the LLVM first |
| 278 | llvm::InitializeAllTargets(); |
| 279 | llvm::InitializeAllTargetMCs(); |
| 280 | llvm::InitializeAllAsmPrinters(); |
| 281 | llvm::InitializeAllAsmParsers(); |
| 282 | |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 283 | // Lookup the LLVM target |
| 284 | char const* target_triple = NULL; |
| 285 | char const* target_attr = NULL; |
| 286 | |
| 287 | switch (insn_set) { |
| 288 | case kThumb2: |
| 289 | target_triple = "thumb-none-linux-gnueabi"; |
| 290 | target_attr = "+thumb2,+neon,+neonfp,+vfp3"; |
| 291 | break; |
| 292 | |
| 293 | case kArm: |
| 294 | target_triple = "armv7-none-linux-gnueabi"; |
| 295 | // TODO: Fix for Xoom. |
| 296 | target_attr = "+v7,+neon,+neonfp,+vfp3"; |
| 297 | break; |
| 298 | |
| 299 | case kX86: |
| 300 | target_triple = "i386-pc-linux-gnu"; |
| 301 | target_attr = ""; |
| 302 | break; |
| 303 | |
| 304 | case kMips: |
| 305 | target_triple = "mipsel-unknown-linux"; |
| 306 | target_attr = "mips32r2"; |
| 307 | break; |
| 308 | |
| 309 | default: |
| 310 | LOG(FATAL) << "Unknown instruction set: " << insn_set; |
| 311 | } |
| 312 | |
| 313 | std::string errmsg; |
| 314 | llvm::Target const* target = |
| 315 | llvm::TargetRegistry::lookupTarget(target_triple, errmsg); |
| 316 | |
| 317 | CHECK(target != NULL) << errmsg; |
| 318 | |
| 319 | // Target options |
| 320 | llvm::TargetOptions target_options; |
| 321 | target_options.FloatABIType = llvm::FloatABI::Soft; |
| 322 | target_options.NoFramePointerElim = true; |
| 323 | target_options.NoFramePointerElimNonLeaf = true; |
| 324 | target_options.UseSoftFloat = false; |
| 325 | target_options.EnableFastISel = true; |
| 326 | |
| 327 | // Create the llvm::TargetMachine |
| 328 | llvm::TargetMachine* target_machine = |
| 329 | target->createTargetMachine(target_triple, "", target_attr, target_options, |
| 330 | llvm::Reloc::Static, llvm::CodeModel::Small, |
| 331 | llvm::CodeGenOpt::Less); |
| 332 | |
| 333 | CHECK(target_machine != NULL) << "Failed to create target machine"; |
| 334 | |
| 335 | // Add target data |
| 336 | llvm::TargetData const* target_data = target_machine->getTargetData(); |
| 337 | |
| 338 | // PassManager for code generation passes |
| 339 | llvm::PassManager pm; |
| 340 | pm.add(new llvm::TargetData(*target_data)); |
| 341 | |
| 342 | // FunctionPassManager for optimization pass |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 343 | llvm::FunctionPassManager fpm(module_); |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 344 | fpm.add(new llvm::TargetData(*target_data)); |
| 345 | |
| 346 | // Add optimization pass |
| 347 | llvm::PassManagerBuilder pm_builder; |
| 348 | pm_builder.Inliner = llvm::createAlwaysInlinerPass(); |
| 349 | pm_builder.OptLevel = 1; |
| 350 | pm_builder.DisableSimplifyLibCalls = 1; |
| 351 | pm_builder.populateModulePassManager(pm); |
| 352 | pm_builder.populateFunctionPassManager(fpm); |
| 353 | |
| 354 | // Add passes to emit ELF image |
| 355 | { |
| 356 | llvm::formatted_raw_ostream formatted_os( |
| 357 | *(new llvm::raw_fd_ostream(output_fd, /* shouldClose */false)), true); |
| 358 | |
| 359 | // Ask the target to add backend passes as necessary. |
| 360 | if (target_machine->addPassesToEmitFile(pm, |
| 361 | formatted_os, |
| 362 | llvm::TargetMachine::CGFT_ObjectFile, |
| 363 | true)) { |
| 364 | LOG(FATAL) << "Unable to generate ELF for this target"; |
| 365 | return false; |
| 366 | } |
| 367 | |
| 368 | // FIXME: Unable to run the UpdateFrameSizePass pass since it tries to |
| 369 | // update the value reside in the different address space. |
| 370 | // Add pass to update the frame_size_in_bytes_ |
| 371 | //pm.add(new ::UpdateFrameSizePass(this)); |
| 372 | |
| 373 | // Run the per-function optimization |
| 374 | fpm.doInitialization(); |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 375 | for (llvm::Module::iterator F = module_->begin(), E = module_->end(); |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 376 | F != E; ++F) { |
| 377 | fpm.run(*F); |
| 378 | } |
| 379 | fpm.doFinalization(); |
| 380 | |
| 381 | // Run the code generation passes |
Logan Chien | 799ef4f | 2012-04-23 00:17:47 +0800 | [diff] [blame] | 382 | pm.run(*module_); |
Shih-wei Liao | d7726e4 | 2012-04-20 15:23:36 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | return true; |
| 386 | } |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 387 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 388 | } // namespace compiler_llvm |
| 389 | } // namespace art |