brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 86c0851 Raw
42 lines · python
1#!/usr/bin/env python2 3from __future__ import print_function4 5import os6import sys7import argparse8import subprocess9 10parser = argparse.ArgumentParser()11 12parser.add_argument("--start", type=int, default=0)13parser.add_argument("--end", type=int, default=(1 << 32))14parser.add_argument("--optcmd", default=("opt"))15parser.add_argument("--filecheckcmd", default=("FileCheck"))16parser.add_argument("--prefix", default=("CHECK-BISECT"))17parser.add_argument("--test", default=(""))18 19args = parser.parse_args()20 21start = args.start22end = args.end23 24opt_command = [args.optcmd, "-O2", "-opt-bisect-limit=%(count)s", "-S", args.test]25check_command = [args.filecheckcmd, args.test, "--check-prefix=%s" % args.prefix]26last = None27while start != end and start != end - 1:28    count = int(round(start + (end - start) / 2))29    cmd = [x % {"count": count} for x in opt_command]30    print("opt: " + str(cmd))31    opt_result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)32    filecheck_result = subprocess.Popen(check_command, stdin=opt_result.stdout)33    opt_result.stdout.close()34    opt_result.stderr.close()35    filecheck_result.wait()36    if filecheck_result.returncode == 0:37        start = count38    else:39        end = count40 41print("Last good count: %d" % start)42