aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEli Bendersky <eliben@chromium.org>2013-07-15 10:57:57 -0700
committerEli Bendersky <eliben@chromium.org>2013-07-15 10:57:57 -0700
commit5b5694819b4ce87f8dd741ee91fbac4c26f413a0 (patch)
tree24e0a86354d260f9b08caec02696eb3174ae75d7 /tools
parentdceeed39b14cc9fc4748e82a67caab2e1d9caafa (diff)
Clean up some duplicated and/or unused code in pnacl-llc.
No functionality change. BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/19235002
Diffstat (limited to 'tools')
-rw-r--r--tools/pnacl-llc/pnacl-llc.cpp73
1 files changed, 12 insertions, 61 deletions
diff --git a/tools/pnacl-llc/pnacl-llc.cpp b/tools/pnacl-llc/pnacl-llc.cpp
index b085a0be57..0b6c7ded61 100644
--- a/tools/pnacl-llc/pnacl-llc.cpp
+++ b/tools/pnacl-llc/pnacl-llc.cpp
@@ -306,7 +306,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
TimeIRParsingIsEnabled);
M.reset(NaClParseIRFile(InputFilename, InputFileFormat, Err, Context));
}
-#endif
+#endif // __native_client__
mod = M.get();
if (mod == 0) {
@@ -472,18 +472,21 @@ static int compileModule(char **argv, LLVMContext &Context) {
Target.setMCRelaxAll(true);
}
-#if defined __native_client__
{
+#if defined(__native_client__)
raw_fd_ostream ROS(GetObjectFileFD(), true);
ROS.SetBufferSize(1 << 20);
formatted_raw_ostream FOS(ROS);
+#else
+ formatted_raw_ostream FOS(Out->os());
+#endif // __native_client__
// Ask the target to add backend passes as necessary. We explicitly ask it
// not to add the verifier pass because we added it earlier.
if (Target.addPassesToEmitFile(*PM, FOS, FileType,
/* DisableVerify */ true)) {
- errs() << argv[0] << ": target does not support generation of this"
- << " file type!\n";
+ errs() << argv[0]
+ << ": target does not support generation of this file type!\n";
return 1;
}
@@ -501,67 +504,15 @@ static int compileModule(char **argv, LLVMContext &Context) {
} else {
static_cast<PassManager*>(PM.get())->run(*mod);
}
+#if defined(__native_client__)
FOS.flush();
ROS.flush();
- }
#else
-
- {
- formatted_raw_ostream FOS(Out->os());
-
- AnalysisID StartAfterID = 0;
- AnalysisID StopAfterID = 0;
- const PassRegistry *PR = PassRegistry::getPassRegistry();
- if (!StartAfter.empty()) {
- const PassInfo *PI = PR->getPassInfo(StartAfter);
- if (!PI) {
- errs() << argv[0] << ": start-after pass is not registered.\n";
- return 1;
- }
- StartAfterID = PI->getTypeInfo();
- }
- if (!StopAfter.empty()) {
- const PassInfo *PI = PR->getPassInfo(StopAfter);
- if (!PI) {
- errs() << argv[0] << ": stop-after pass is not registered.\n";
- return 1;
- }
- StopAfterID = PI->getTypeInfo();
- }
-
- // Ask the target to add backend passes as necessary.
- // TODO: decrease the amount of code duplication with __native_client__
- if (Target.addPassesToEmitFile(*PM, FOS, FileType,
- /* DisableVerify */ true,
- StartAfterID, StopAfterID)) {
- errs() << argv[0] << ": target does not support generation of this"
- << " file type!\n";
- return 1;
- }
-
- // Before executing passes, print the final values of the LLVM options.
- cl::PrintOptionValues();
-
- if (LazyBitcode || ReduceMemoryFootprint) {
- FunctionPassManager *P = static_cast<FunctionPassManager*>(PM.get());
- P->doInitialization();
- for (Module::iterator I = mod->begin(), E = mod->end(); I != E; ++I) {
- P->run(*I);
- CheckABIVerifyErrors(ABIErrorReporter, "Function " + I->getName());
- if (ReduceMemoryFootprint) {
- I->Dematerialize();
- }
- }
- P->doFinalization();
- } else {
- static_cast<PassManager*>(PM.get())->run(*mod);
- }
+ // Declare success.
+ Out->keep();
+#endif // __native_client__
}
- // Declare success.
- Out->keep();
-#endif
-
return 0;
}
@@ -572,4 +523,4 @@ main (int argc, char **argv) {
}
#else
// main() is in nacl_file.cpp.
-#endif
+#endif // __native_client__