diff options
author | Eli Bendersky <eliben@chromium.org> | 2013-06-20 15:27:32 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@chromium.org> | 2013-06-20 15:27:32 -0700 |
commit | 3d33e93d36fd65b2df1afe946b9745fc239b2ad7 (patch) | |
tree | fc9a547800334efaf8481219aa589b5a16d23b22 /tools | |
parent | 402eecfe0abd2f99580d81440f264067095b7a43 (diff) |
Clean-up pnacl-llc a bit, now that it's truly PNaCl-only.
No changes in functionality. Specific cleanups:
* Use OwningPtr instead of bare pointer for FDOut
* Command-line help should say pnacl-llc instead of a generic llvm message
* Remove support for "skip module" feature
* Remove some LOCALMOD comments
* Add link to issue for TODO about timing IR parsing
BUG=None
R=jvoung@chromium.org, kschimpf@google.com
Review URL: https://codereview.chromium.org/17101032
Diffstat (limited to 'tools')
-rw-r--r-- | tools/pnacl-llc/pnacl-llc.cpp | 103 |
1 files changed, 44 insertions, 59 deletions
diff --git a/tools/pnacl-llc/pnacl-llc.cpp b/tools/pnacl-llc/pnacl-llc.cpp index a2a6f3ec05..40f1a4e8db 100644 --- a/tools/pnacl-llc/pnacl-llc.cpp +++ b/tools/pnacl-llc/pnacl-llc.cpp @@ -210,15 +210,14 @@ static tool_output_file *GetOutputStream(const char *TargetName, std::string error; unsigned OpenFlags = 0; if (Binary) OpenFlags |= raw_fd_ostream::F_Binary; - tool_output_file *FDOut = new tool_output_file(OutputFilename.c_str(), error, - OpenFlags); + OwningPtr<tool_output_file> FDOut( + new tool_output_file(OutputFilename.c_str(), error, OpenFlags)); if (!error.empty()) { errs() << error << '\n'; - delete FDOut; return 0; } - return FDOut; + return FDOut.take(); } // main - Entry point for the llc compiler. @@ -264,7 +263,7 @@ int llc_main(int argc, char **argv) { PNaClABIVerifyFatalErrors = true; #endif - cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n"); + cl::ParseCommandLineOptions(argc, argv, "pnacl-llc\n"); // Compile the module TimeCompilations times to give better compile time // metrics. @@ -295,67 +294,54 @@ static int compileModule(char **argv, LLVMContext &Context) { Module *mod = 0; Triple TheTriple; - bool SkipModule = MCPU == "help" || - (!MAttrs.empty() && MAttrs.front() == "help"); + PNaClABIErrorReporter ABIErrorReporter; - PNaClABIErrorReporter ABIErrorReporter; // @LOCALMOD - - // If user just wants to list available options, skip module loading - if (!SkipModule) { - // @LOCALMOD-BEGIN #if defined(__native_client__) - if (LazyBitcode) { - std::string StrError; - M.reset(getNaClStreamedBitcodeModule( - std::string("<SRPC stream>"), - NaClBitcodeStreamer, Context, &StrError)); - if (!StrError.empty()) - Err = SMDiagnostic(InputFilename, SourceMgr::DK_Error, StrError); - } else { - // Avoid using ParseIRFile to avoid pulling in the LLParser. - // Only handle binary bitcode. - llvm_unreachable("native client SRPC only supports streaming"); - } + if (LazyBitcode) { + std::string StrError; + M.reset(getNaClStreamedBitcodeModule( + std::string("<SRPC stream>"), + NaClBitcodeStreamer, Context, &StrError)); + if (!StrError.empty()) + Err = SMDiagnostic(InputFilename, SourceMgr::DK_Error, StrError); + } else { + llvm_unreachable("native client SRPC only supports streaming"); + } #else - { - // @LOCALMOD: timing is temporary, until it gets properly added upstream - NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName, - TimeIRParsingIsEnabled); - M.reset(NaClParseIRFile(InputFilename, InputFileFormat, Err, Context)); - } + { + // TODO: after the next merge this can be removed. + // https://code.google.com/p/nativeclient/issues/detail?id=3349 + NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName, + TimeIRParsingIsEnabled); + M.reset(NaClParseIRFile(InputFilename, InputFileFormat, Err, Context)); + } #endif - // @LOCALMOD-END - mod = M.get(); - if (mod == 0) { - Err.print(argv[0], errs()); - return 1; - } + mod = M.get(); + if (mod == 0) { + Err.print(argv[0], errs()); + return 1; + } - // @LOCALMOD-BEGIN - if (PNaClABIVerify) { - // Verify the module (but not the functions yet) - ModulePass *VerifyPass = createPNaClABIVerifyModulePass(&ABIErrorReporter, - LazyBitcode); - VerifyPass->runOnModule(*mod); - CheckABIVerifyErrors(ABIErrorReporter, "Module"); - } + if (PNaClABIVerify) { + // Verify the module (but not the functions yet) + ModulePass *VerifyPass = createPNaClABIVerifyModulePass(&ABIErrorReporter, + LazyBitcode); + VerifyPass->runOnModule(*mod); + CheckABIVerifyErrors(ABIErrorReporter, "Module"); + } - // Add declarations for external functions required by PNaCl. The - // ResolvePNaClIntrinsics function pass running during streaming - // depends on these declarations being in the module. - OwningPtr<ModulePass> AddPNaClExternalDeclsPass( - createAddPNaClExternalDeclsPass()); - AddPNaClExternalDeclsPass->runOnModule(*mod); - // @LOCALMOD-END + // Add declarations for external functions required by PNaCl. The + // ResolvePNaClIntrinsics function pass running during streaming + // depends on these declarations being in the module. + OwningPtr<ModulePass> AddPNaClExternalDeclsPass( + createAddPNaClExternalDeclsPass()); + AddPNaClExternalDeclsPass->runOnModule(*mod); - // If we are supposed to override the target triple, do so now. - if (!TargetTriple.empty()) - mod->setTargetTriple(Triple::normalize(TargetTriple)); - TheTriple = Triple(mod->getTargetTriple()); - } else { - TheTriple = Triple(Triple::normalize(TargetTriple)); - } + // If we are supposed to override the target triple, do so now. + if (!TargetTriple.empty()) + mod->setTargetTriple(Triple::normalize(TargetTriple)); + TheTriple = Triple(mod->getTargetTriple()); if (TheTriple.getTriple().empty()) TheTriple.setTriple(sys::getDefaultTargetTriple()); @@ -497,7 +483,6 @@ static int compileModule(char **argv, LLVMContext &Context) { Target.setMCRelaxAll(true); } - #if defined __native_client__ { raw_fd_ostream ROS(GetObjectFileFD(), true); |