diff options
author | Keno Fischer <kfischer@college.harvard.edu> | 2015-12-05 01:38:12 +0000 |
---|---|---|
committer | Keno Fischer <kfischer@college.harvard.edu> | 2015-12-05 01:38:12 +0000 |
commit | e54f58c7c5f13ecc3ef9302bbb05d95e857f7389 (patch) | |
tree | 82ef3d1c7d31fe52933bb1d68223a85362ce6543 | |
parent | a330293af79489abd0e90482794bdf4f0718a323 (diff) | |
download | bcm5719-llvm-e54f58c7c5f13ecc3ef9302bbb05d95e857f7389.tar.gz bcm5719-llvm-e54f58c7c5f13ecc3ef9302bbb05d95e857f7389.zip |
[opt] Fix run-twice option for non-idempotent passes
Cloning the module was supposed to guard against the possibility
that the passes may be non-idempotent. However, for some reason
I decided to put that AFTER the passes had already run on the
module, defeating the point entirely. Fix that by moving up the
CloneModule as is done in llc.
llvm-svn: 254819
-rw-r--r-- | llvm/tools/opt/opt.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index fc31beb4815..fe1605aa843 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/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<Module> 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<Module> 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(); |