| # Given a -print-before-all -print-module-scope log from an opt invocation, |
| # chunk it into a series of individual IR files, one for each pass invocation. |
| # If the log ends with an obvious stack trace, try to split off a separate |
| # "crashinfo.txt" file leaving only the valid input IR in the last chunk. |
| # Files are written to current working directory. |
| from __future__ import print_function |
| fname = basename + str(chunk_id) + ".ll" |
| print("writing chunk " + fname + " (" + str(len(lines)) + " lines)") |
| with open(fname, "w") as f: |
| if line.startswith("*** IR Dump Before "): |
| elif line.startswith("Stack dump:"): |
| print("writing crashinfo.txt (" + str(len(cur)) + " lines)") |
| with open("crashinfo.txt", "w") as f: |