Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2024)

Side by Side Diff: tools/llc/llc.cpp

Issue 8393017: Bitcode streaming (Closed)
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===// 1 //===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This is the llc code generator driver. It provides a convenient 10 // This is the llc code generator driver. It provides a convenient
11 // command-line interface for generating native assembly-language code 11 // command-line interface for generating native assembly-language code
12 // or C code, given LLVM bitcode. 12 // or C code, given LLVM bitcode.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "llvm/LLVMContext.h" 16 #include "llvm/LLVMContext.h"
17 #include "llvm/Module.h" 17 #include "llvm/Module.h"
18 #include "llvm/PassManager.h" 18 #include "llvm/PassManager.h"
19 #include "llvm/Pass.h" 19 #include "llvm/Pass.h"
20 #include "llvm/ADT/Triple.h" 20 #include "llvm/ADT/Triple.h"
21 #include "llvm/Bitcode/BitcodeStream.h"
21 #include "llvm/Support/IRReader.h" 22 #include "llvm/Support/IRReader.h"
22 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h" 23 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
23 #include "llvm/CodeGen/LinkAllCodegenComponents.h" 24 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
24 #include "llvm/Config/config.h" 25 #include "llvm/Config/config.h"
25 #include "llvm/MC/SubtargetFeature.h" 26 #include "llvm/MC/SubtargetFeature.h"
26 #include "llvm/Support/CommandLine.h" 27 #include "llvm/Support/CommandLine.h"
27 #include "llvm/Support/Debug.h" 28 #include "llvm/Support/Debug.h"
28 #include "llvm/Support/FormattedStream.h" 29 #include "llvm/Support/FormattedStream.h"
29 #include "llvm/Support/ManagedStatic.h" 30 #include "llvm/Support/ManagedStatic.h"
30 #if !defined(__native_client__) 31 #if !defined(__native_client__)
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 std::auto_ptr<Module> M; 323 std::auto_ptr<Module> M;
323 324
324 // In the NACL_SRPC case, fake a memory mapped file 325 // In the NACL_SRPC case, fake a memory mapped file
325 // TODO(jvoung): revert changes in MemoryBuffer.cpp which are no longer needed 326 // TODO(jvoung): revert changes in MemoryBuffer.cpp which are no longer needed
326 #if defined(__native_client__) && defined(NACL_SRPC) 327 #if defined(__native_client__) && defined(NACL_SRPC)
327 M.reset(ParseIR(NaClGetMemoryBufferForFile(InputFilename.c_str()), 328 M.reset(ParseIR(NaClGetMemoryBufferForFile(InputFilename.c_str()),
328 Err, 329 Err,
329 Context)); 330 Context));
330 M->setModuleIdentifier(InputFilename); 331 M->setModuleIdentifier(InputFilename);
331 #else 332 #else
332 M.reset(ParseIRFile(InputFilename, Err, Context)); 333 //M.reset(ParseIRFile(InputFilename, Err, Context));
334 StreamChunkCallback cb = GetBitcodeFileStream(InputFilename, Err);
335 if (cb) {
336 M.reset(getLazyIRStreamModule(InputFilename, Err, Context, cb));
337 }
333 #endif // defined(__native_client__) && defined(NACL_SRPC) 338 #endif // defined(__native_client__) && defined(NACL_SRPC)
334 if (M.get() == 0) { 339 if (M.get() == 0) {
335 Err.print(argv[0], errs()); 340 Err.print(argv[0], errs());
336 return 1; 341 return 1;
337 } 342 }
338 Module &mod = *M.get(); 343 Module &mod = *M.get();
339 344
340 // @LOCALMOD-BEGIN 345 // @LOCALMOD-BEGIN
341 if (!DumpMetadata.empty()) { 346 if (!DumpMetadata.empty()) {
342 bool success = WriteMetadata(DumpMetadata.c_str(), mod); 347 bool success = WriteMetadata(DumpMetadata.c_str(), mod);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 errs() << argv[0] << ": invalid optimization level.\n"; 443 errs() << argv[0] << ": invalid optimization level.\n";
439 return 1; 444 return 1;
440 case ' ': break; 445 case ' ': break;
441 case '0': OLvl = CodeGenOpt::None; break; 446 case '0': OLvl = CodeGenOpt::None; break;
442 case '1': OLvl = CodeGenOpt::Less; break; 447 case '1': OLvl = CodeGenOpt::Less; break;
443 case '2': OLvl = CodeGenOpt::Default; break; 448 case '2': OLvl = CodeGenOpt::Default; break;
444 case '3': OLvl = CodeGenOpt::Aggressive; break; 449 case '3': OLvl = CodeGenOpt::Aggressive; break;
445 } 450 }
446 451
447 // Build up all of the passes that we want to do to the module. 452 // Build up all of the passes that we want to do to the module.
448 PassManager PM; 453 FunctionPassManager PM(&mod);
449 454
450 // Add the target data from the target machine, if it exists, or the module. 455 // Add the target data from the target machine, if it exists, or the module.
451 if (const TargetData *TD = Target.getTargetData()) 456 if (const TargetData *TD = Target.getTargetData())
452 PM.add(new TargetData(*TD)); 457 PM.add(new TargetData(*TD));
453 else 458 else
454 PM.add(new TargetData(&mod)); 459 PM.add(new TargetData(&mod));
455 460
456 // Override default to generate verbose assembly. 461 // Override default to generate verbose assembly.
457 Target.setAsmVerbosityDefault(true); 462 Target.setAsmVerbosityDefault(true);
458 463
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // Ask the target to add backend passes as necessary. 496 // Ask the target to add backend passes as necessary.
492 if (Target.addPassesToEmitFile(PM, FOS, FileType, OLvl, NoVerify)) { 497 if (Target.addPassesToEmitFile(PM, FOS, FileType, OLvl, NoVerify)) {
493 errs() << argv[0] << ": target does not support generation of this" 498 errs() << argv[0] << ": target does not support generation of this"
494 << " file type!\n"; 499 << " file type!\n";
495 return 1; 500 return 1;
496 } 501 }
497 502
498 // Before executing passes, print the final values of the LLVM options. 503 // Before executing passes, print the final values of the LLVM options.
499 cl::PrintOptionValues(); 504 cl::PrintOptionValues();
500 505
501 PM.run(mod); 506 PM.doInitialization();
jasonwkim 2011/10/25 21:34:12 Why did you expand this?
(google.com) Derek Schuff 2011/10/25 22:23:22 Because the module-level pass manager caused the w
507 for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I) {
508 PM.run(*I);
509 }
510 PM.doFinalization();
502 } 511 }
503 512
504 // Declare success. 513 // Declare success.
505 Out->keep(); 514 Out->keep();
506 #endif 515 #endif
507 516
508 return 0; 517 return 0;
509 } 518 }
510 519
511 #if !defined(NACL_SRPC) 520 #if !defined(NACL_SRPC)
512 int 521 int
513 main (int argc, char **argv) { 522 main (int argc, char **argv) {
514 return llc_main(argc, argv); 523 return llc_main(argc, argv);
515 } 524 }
516 #else 525 #else
517 // main() is in nacl_file.cpp. 526 // main() is in nacl_file.cpp.
518 #endif 527 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698