X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fopt%2Fopt.cpp;h=fe1605aa8436fce105c5fb79cf0e0371aa6f4830;hb=7609bf251117db67abfe0d5b6622860afc769278;hp=fc31beb48154d5a33f85f1d331c234c5a51ed9cd;hpb=357108cbea3d64a0f31b931121d4a381ee6c1a3b;p=oota-llvm.git diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index fc31beb4815..fe1605aa843 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -614,22 +614,26 @@ int main(int argc, char **argv) { // Before executing passes, print the final values of the LLVM options. cl::PrintOptionValues(); + // If requested, run all passes again with the same pass manager to catch + // bugs caused by persistent state in the passes + if (RunTwice) { + std::unique_ptr M2(CloneModule(M.get())); + Passes.run(*M2); + CompileTwiceBuffer = Buffer; + Buffer.clear(); + } + // Now that we have all of the passes ready, run them. Passes.run(*M); - // If requested, run all passes again with the same pass manager to catch - // bugs caused by persistent state in the passes + // Compare the two outputs and make sure they're the same if (RunTwice) { assert(Out); - CompileTwiceBuffer = Buffer; - Buffer.clear(); - std::unique_ptr M2(CloneModule(M.get())); - Passes.run(*M2); if (Buffer.size() != CompileTwiceBuffer.size() || (memcmp(Buffer.data(), CompileTwiceBuffer.data(), Buffer.size()) != 0)) { errs() << "Running the pass manager twice changed the output.\n" - "Writing the result of the second run to the specified output." + "Writing the result of the second run to the specified output.\n" "To generate the one-run comparison binary, just run without\n" "the compile-twice option\n"; Out->os() << BOS->str();