| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 errs() << os.str(); | 317 errs() << os.str(); |
| 318 } | 318 } |
| 319 Reporter.reset(); | 319 Reporter.reset(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 static Module* getModule(StringRef ProgramName, LLVMContext &Context, | 322 static Module* getModule(StringRef ProgramName, LLVMContext &Context, |
| 323 StreamingMemoryObject *StreamingObject) { | 323 StreamingMemoryObject *StreamingObject) { |
| 324 Module *M = nullptr; | 324 Module *M = nullptr; |
| 325 SMDiagnostic Err; | 325 SMDiagnostic Err; |
| 326 std::string VerboseBuffer; |
| 327 raw_string_ostream VerboseStrm(VerboseBuffer); |
| 326 if (LazyBitcode) { | 328 if (LazyBitcode) { |
| 327 std::string StrError; | 329 std::string StrError; |
| 328 if (InputFileFormat == PNaClFormat) { | 330 if (InputFileFormat == PNaClFormat) { |
| 329 M = getNaClStreamedBitcodeModule( | 331 M = getNaClStreamedBitcodeModule( |
| 330 InputFilename, | 332 InputFilename, |
| 331 new ThreadedStreamingCache(StreamingObject), Context, &StrError); | 333 new ThreadedStreamingCache(StreamingObject), Context, &VerboseStrm, |
| 334 &StrError); |
| 332 } else if (InputFileFormat == LLVMFormat) { | 335 } else if (InputFileFormat == LLVMFormat) { |
| 333 M = getStreamedBitcodeModule( | 336 M = getStreamedBitcodeModule( |
| 334 InputFilename, | 337 InputFilename, |
| 335 new ThreadedStreamingCache(StreamingObject), Context, &StrError); | 338 new ThreadedStreamingCache(StreamingObject), Context, &StrError); |
| 336 } else { | 339 } else { |
| 337 llvm_unreachable("Unknown bitcode format"); | 340 llvm_unreachable("Unknown bitcode format"); |
| 338 } | 341 } |
| 339 if (!StrError.empty()) | 342 if (!StrError.empty()) |
| 340 Err = SMDiagnostic(InputFilename, SourceMgr::DK_Error, StrError); | 343 Err = SMDiagnostic(InputFilename, SourceMgr::DK_Error, StrError); |
| 341 } else { | 344 } else { |
| 342 #if defined(__native_client__) | 345 #if defined(__native_client__) |
| 343 llvm_unreachable("native client SRPC only supports streaming"); | 346 llvm_unreachable("native client SRPC only supports streaming"); |
| 344 #else | 347 #else |
| 345 // Parses binary bitcode as well as textual assembly | 348 // Parses binary bitcode as well as textual assembly |
| 346 // (so pulls in more code into pnacl-llc). | 349 // (so pulls in more code into pnacl-llc). |
| 347 M = NaClParseIRFile(InputFilename, InputFileFormat, Err, Context); | 350 M = NaClParseIRFile(InputFilename, InputFileFormat, Err, &VerboseStrm, |
| 351 Context); |
| 348 #endif | 352 #endif |
| 349 } | 353 } |
| 350 if (!M) { | 354 if (!M) { |
| 351 #if defined(__native_client__) | 355 #if defined(__native_client__) |
| 352 report_fatal_error(Err.getMessage()); | 356 report_fatal_error(VerboseStrm.str() + Err.getMessage()); |
| 353 #else | 357 #else |
| 354 // Err.print is prettier, so use it for the non-sandboxed translator. | 358 // Err.print is prettier, so use it for the non-sandboxed translator. |
| 355 Err.print(ProgramName.data(), errs()); | 359 Err.print(ProgramName.data(), errs()); |
| 360 errs() << VerboseStrm.str(); |
| 356 return nullptr; | 361 return nullptr; |
| 357 #endif | 362 #endif |
| 358 } | 363 } |
| 359 return M; | 364 return M; |
| 360 } | 365 } |
| 361 | 366 |
| 362 static cl::opt<bool> | 367 static cl::opt<bool> |
| 363 ExternalizeAll("externalize", | 368 ExternalizeAll("externalize", |
| 364 cl::desc("Externalize all symbols"), | 369 cl::desc("Externalize all symbols"), |
| 365 cl::init(false)); | 370 cl::init(false)); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 return 0; | 772 return 0; |
| 768 } | 773 } |
| 769 | 774 |
| 770 int main(int argc, char **argv) { | 775 int main(int argc, char **argv) { |
| 771 #if defined(__native_client__) | 776 #if defined(__native_client__) |
| 772 return srpc_main(argc, argv); | 777 return srpc_main(argc, argv); |
| 773 #else | 778 #else |
| 774 return llc_main(argc, argv); | 779 return llc_main(argc, argv); |
| 775 #endif // __native_client__ | 780 #endif // __native_client__ |
| 776 } | 781 } |
| OLD | NEW |