annotate llvm/utils/bisect @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 #!/usr/bin/env python
anatofuz
parents:
diff changeset
2 #
anatofuz
parents:
diff changeset
3 # The way you use this is you create a script that takes in as its first
anatofuz
parents:
diff changeset
4 # argument a count. The script passes into LLVM the count via a command
anatofuz
parents:
diff changeset
5 # line flag that disables a pass after LLVM has run after the pass has
anatofuz
parents:
diff changeset
6 # run for count number of times. Then the script invokes a test of some
anatofuz
parents:
diff changeset
7 # sort and indicates whether LLVM successfully compiled the test via the
anatofuz
parents:
diff changeset
8 # scripts exit status. Then you invoke bisect as follows:
anatofuz
parents:
diff changeset
9 #
anatofuz
parents:
diff changeset
10 # bisect --start=<start_num> --end=<end_num> ./script.sh "%(count)s"
anatofuz
parents:
diff changeset
11 #
anatofuz
parents:
diff changeset
12 # And bisect will continually call ./script.sh with various counts using
anatofuz
parents:
diff changeset
13 # the exit status to determine success and failure.
anatofuz
parents:
diff changeset
14 #
anatofuz
parents:
diff changeset
15 from __future__ import print_function
anatofuz
parents:
diff changeset
16 import os
anatofuz
parents:
diff changeset
17 import sys
anatofuz
parents:
diff changeset
18 import argparse
anatofuz
parents:
diff changeset
19 import subprocess
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 parser = argparse.ArgumentParser()
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 parser.add_argument('--start', type=int, default=0)
anatofuz
parents:
diff changeset
24 parser.add_argument('--end', type=int, default=(1 << 32))
anatofuz
parents:
diff changeset
25 parser.add_argument('command', nargs='+')
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 args = parser.parse_args()
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 start = args.start
anatofuz
parents:
diff changeset
30 end = args.end
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 print("Bisect Starting!")
anatofuz
parents:
diff changeset
33 print("Start: %d" % start)
anatofuz
parents:
diff changeset
34 print("End: %d" % end)
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 last = None
anatofuz
parents:
diff changeset
37 while start != end and start != end-1:
anatofuz
parents:
diff changeset
38 count = start + (end - start)//2
anatofuz
parents:
diff changeset
39 print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))
anatofuz
parents:
diff changeset
40 cmd = [x % {'count':count} for x in args.command]
anatofuz
parents:
diff changeset
41 print(cmd)
anatofuz
parents:
diff changeset
42 result = subprocess.call(cmd)
anatofuz
parents:
diff changeset
43 if result == 0:
anatofuz
parents:
diff changeset
44 print(" PASSES! Setting start to count")
anatofuz
parents:
diff changeset
45 start = count
anatofuz
parents:
diff changeset
46 else:
anatofuz
parents:
diff changeset
47 print(" FAILS! Setting end to count")
anatofuz
parents:
diff changeset
48 end = count
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 print("Last good count: %d" % start)