OLD | NEW |
1 //===-- pnacl-llc.cpp - PNaCl-specific llc: pexe ---> nexe ---------------===// | 1 //===-- pnacl-llc.cpp - PNaCl-specific llc: pexe ---> nexe ---------------===// |
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 // pnacl-llc: the core of the PNaCl translator, compiling a pexe into a nexe. | 10 // pnacl-llc: the core of the PNaCl translator, compiling a pexe into a nexe. |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 std::unique_ptr<Module> M; | 360 std::unique_ptr<Module> M; |
361 SMDiagnostic Err; | 361 SMDiagnostic Err; |
362 std::string VerboseBuffer; | 362 std::string VerboseBuffer; |
363 raw_string_ostream VerboseStrm(VerboseBuffer); | 363 raw_string_ostream VerboseStrm(VerboseBuffer); |
364 if (LazyBitcode) { | 364 if (LazyBitcode) { |
365 std::string StrError; | 365 std::string StrError; |
366 switch (InputFileFormat) { | 366 switch (InputFileFormat) { |
367 case PNaClFormat: { | 367 case PNaClFormat: { |
368 std::unique_ptr<StreamingMemoryObject> Cache( | 368 std::unique_ptr<StreamingMemoryObject> Cache( |
369 new ThreadedStreamingCache(StreamingObject)); | 369 new ThreadedStreamingCache(StreamingObject)); |
| 370 DiagnosticHandlerFunction DiagnosticHandler = nullptr; |
370 M.reset(getNaClStreamedBitcodeModule( | 371 M.reset(getNaClStreamedBitcodeModule( |
371 InputFilename, Cache.release(), Context, &VerboseStrm, &StrError)); | 372 InputFilename, Cache.release(), Context, |
| 373 redirectNaClDiagnosticToStream(VerboseStrm), &StrError)); |
372 break; | 374 break; |
373 } | 375 } |
374 case LLVMFormat: { | 376 case LLVMFormat: { |
375 std::unique_ptr<StreamingMemoryObject> Cache( | 377 std::unique_ptr<StreamingMemoryObject> Cache( |
376 new ThreadedStreamingCache(StreamingObject)); | 378 new ThreadedStreamingCache(StreamingObject)); |
377 ErrorOr<std::unique_ptr<Module>> MOrErr = | 379 ErrorOr<std::unique_ptr<Module>> MOrErr = |
378 getStreamedBitcodeModule( | 380 getStreamedBitcodeModule(InputFilename, Cache.release(), Context, |
379 InputFilename, Cache.release(), Context); | 381 redirectNaClDiagnosticToStream(VerboseStrm)); |
380 M = std::move(*MOrErr); | 382 M = std::move(*MOrErr); |
381 break; | 383 break; |
382 } | 384 } |
383 case AutodetectFileFormat: | 385 case AutodetectFileFormat: |
384 report_fatal_error("Command can't autodetect file format!"); | 386 report_fatal_error("Command can't autodetect file format!"); |
385 } | 387 } |
386 if (!StrError.empty()) | 388 if (!StrError.empty()) |
387 Err = SMDiagnostic(InputFilename, SourceMgr::DK_Error, StrError); | 389 Err = SMDiagnostic(InputFilename, SourceMgr::DK_Error, StrError); |
388 } else { | 390 } else { |
389 #if defined(PNACL_BROWSER_TRANSLATOR) | 391 #if defined(PNACL_BROWSER_TRANSLATOR) |
390 llvm_unreachable("native client SRPC only supports streaming"); | 392 llvm_unreachable("native client SRPC only supports streaming"); |
391 #else | 393 #else |
392 if (AcceptBitcodeRecordText) { | 394 if (AcceptBitcodeRecordText) { |
393 M = parseBitcodeRecordsAsText(InputFilename, Err, &VerboseStrm, Context); | 395 M = parseBitcodeRecordsAsText(InputFilename, Err, &VerboseStrm, Context); |
394 } else { | 396 } else { |
395 // Parses binary bitcode as well as textual assembly | 397 // Parses binary bitcode as well as textual assembly |
396 // (so pulls in more code into pnacl-llc). | 398 // (so pulls in more code into pnacl-llc). |
397 M = NaClParseIRFile(InputFilename, InputFileFormat, Err, &VerboseStrm, | 399 M = NaClParseIRFile(InputFilename, InputFileFormat, Err, Context, |
398 Context); | 400 redirectNaClDiagnosticToStream(VerboseStrm)); |
399 } | 401 } |
400 #endif | 402 #endif |
401 } | 403 } |
402 if (!M) { | 404 if (!M) { |
403 #if defined(PNACL_BROWSER_TRANSLATOR) | 405 #if defined(PNACL_BROWSER_TRANSLATOR) |
404 report_fatal_error(VerboseStrm.str() + Err.getMessage()); | 406 report_fatal_error(VerboseStrm.str() + Err.getMessage()); |
405 #else | 407 #else |
406 // Err.print is prettier, so use it for the non-sandboxed translator. | 408 // Err.print is prettier, so use it for the non-sandboxed translator. |
407 Err.print(ProgramName.data(), errs()); | 409 Err.print(ProgramName.data(), errs()); |
408 errs() << VerboseStrm.str(); | 410 errs() << VerboseStrm.str(); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 return 0; | 827 return 0; |
826 } | 828 } |
827 | 829 |
828 int main(int argc, char **argv) { | 830 int main(int argc, char **argv) { |
829 #if defined(PNACL_BROWSER_TRANSLATOR) | 831 #if defined(PNACL_BROWSER_TRANSLATOR) |
830 return srpc_main(argc, argv); | 832 return srpc_main(argc, argv); |
831 #else | 833 #else |
832 return llc_main(argc, argv); | 834 return llc_main(argc, argv); |
833 #endif // PNACL_BROWSER_TRANSLATOR | 835 #endif // PNACL_BROWSER_TRANSLATOR |
834 } | 836 } |
OLD | NEW |