[RISCV] Eliminate dead li after emitting VSETVLIs (#65934)
[llvm-project.git] / llvm / utils / bisect
blob9df2cd9e1136bc9fedbf3c57f449854346d45d5e
1 #!/usr/bin/env python
3 # The way you use this is you create a script that takes in as its first
4 # argument a count. The script passes into LLVM the count via a command
5 # line flag that disables a pass after LLVM has run after the pass has
6 # run for count number of times. Then the script invokes a test of some
7 # sort and indicates whether LLVM successfully compiled the test via the
8 # scripts exit status. Then you invoke bisect as follows:
10 # bisect --start=<start_num> --end=<end_num> ./script.sh "%(count)s"
12 # And bisect will continually call ./script.sh with various counts using
13 # the exit status to determine success and failure.
15 from __future__ import print_function
16 import os
17 import sys
18 import argparse
19 import subprocess
21 parser = argparse.ArgumentParser()
23 parser.add_argument('--start', type=int, default=0)
24 parser.add_argument('--end', type=int, default=(1 << 32))
25 parser.add_argument('command', nargs='+')
27 args = parser.parse_args()
29 start = args.start
30 end = args.end
32 print("Bisect Starting!")
33 print("Start: %d" % start)
34 print("End: %d" % end)
36 last = None
37 while start != end and start != end-1:
38 count = start + (end - start)//2
39 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 = count
46 else:
47 print(" FAILS! Setting end to count")
48 end = count
50 print("Last good count: %d" % start)