brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 9df2cd9 Raw
51 lines · plain
1#!/usr/bin/env python2#3# The way you use this is you create a script that takes in as its first4# argument a count. The script passes into LLVM the count via a command5# line flag that disables a pass after LLVM has run after the pass has6# run for count number of times. Then the script invokes a test of some7# sort and indicates whether LLVM successfully compiled the test via the8# scripts exit status. Then you invoke bisect as follows:9#10# bisect --start=<start_num> --end=<end_num> ./script.sh "%(count)s"11#12# And bisect will continually call ./script.sh with various counts using13# the exit status to determine success and failure.14#15from __future__ import print_function16import os17import sys18import argparse19import subprocess20 21parser = argparse.ArgumentParser()22 23parser.add_argument('--start', type=int, default=0)24parser.add_argument('--end', type=int, default=(1 << 32))25parser.add_argument('command', nargs='+')26 27args = parser.parse_args()28 29start = args.start30end = args.end31 32print("Bisect Starting!")33print("Start: %d" % start)34print("End: %d" % end)35 36last = None37while start != end and start != end-1:38    count = start + (end - start)//239    print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))40    cmd = [x % {'count':count} for x in args.command]41    print(cmd)42    result = subprocess.call(cmd)43    if result == 0:44        print("    PASSES! Setting start to count")45        start = count46    else:47        print("    FAILS! Setting end to count")48        end = count49 50print("Last good count: %d" % start)51