diff options
author | Eli Bendersky <eliben@chromium.org> | 2013-07-18 18:00:27 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@chromium.org> | 2013-07-18 18:00:27 -0700 |
commit | 4412ea4b8e019d00dc7574fe1723eea0473a8ec1 (patch) | |
tree | 2badd5ce0727bfad02f10d0d82c8bcfa65677676 /tools | |
parent | 4a9f2a703db400ccf760f34101bcdd57642f96e4 (diff) | |
parent | 5b548094edef39376e17445aea28ad2b37d701c4 (diff) |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'tools')
-rw-r--r-- | tools/opt/opt.cpp | 3 | ||||
-rw-r--r-- | tools/pnacl-llc/pnacl-llc.cpp | 85 |
2 files changed, 26 insertions, 62 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index a4e3abef91..a9c19a33dc 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -613,8 +613,8 @@ int main(int argc, char **argv) { initializeExpandGetElementPtrPass(Registry); initializeExpandSmallArgumentsPass(Registry); initializeExpandStructRegsPass(Registry); - initializeExpandTlsPass(Registry); initializeExpandTlsConstantExprPass(Registry); + initializeExpandTlsPass(Registry); initializeExpandVarArgsPass(Registry); initializeFlattenGlobalsPass(Registry); initializeGlobalCleanupPass(Registry); @@ -626,6 +626,7 @@ int main(int argc, char **argv) { initializeReplacePtrsWithIntsPass(Registry); initializeResolveAliasesPass(Registry); initializeResolvePNaClIntrinsicsPass(Registry); + initializeRewriteAtomicsPass(Registry); initializeRewriteLLVMIntrinsicsPass(Registry); initializeRewritePNaClLibraryCallsPass(Registry); initializeStripAttributesPass(Registry); diff --git a/tools/pnacl-llc/pnacl-llc.cpp b/tools/pnacl-llc/pnacl-llc.cpp index 42fde81266..6c79555b14 100644 --- a/tools/pnacl-llc/pnacl-llc.cpp +++ b/tools/pnacl-llc/pnacl-llc.cpp @@ -13,6 +13,7 @@ #include "llvm/ADT/Triple.h" #include "llvm/Analysis/NaCl.h" +#include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/DataStream.h" #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" @@ -305,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) { @@ -428,6 +429,13 @@ static int compileModule(char **argv, LLVMContext &Context) { else PM.reset(new PassManager()); + // For conformance with llc, we let the user disable LLVM IR verification with + // -disable-verify. Unlike llc, when LLVM IR verification is enabled we only + // run it once, before PNaCl ABI verification. + if (!NoVerify) { + PM->add(createVerifierPass()); + } + // Add the ABI verifier pass before the analysis and code emission passes. FunctionPass *FunctionVerifyPass = NULL; if (PNaClABIVerify) { @@ -464,16 +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. - if (Target.addPassesToEmitFile(*PM, FOS, FileType, NoVerify)) { - errs() << argv[0] << ": target does not support generation of this" - << " file type!\n"; + // 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"; return 1; } @@ -491,65 +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. - if (Target.addPassesToEmitFile(*PM, FOS, FileType, NoVerify, - 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; } @@ -560,4 +523,4 @@ main (int argc, char **argv) { } #else // main() is in nacl_file.cpp. -#endif +#endif // __native_client__ |