def invoke_function_bug_reducer(args): """Given a path to a sib file with canonical sil, attempt to find a perturbed list of function given a specific pass that causes the perf pipeline to crash """ tools = bug_reducer_utils.SwiftTools(args.swift_build_dir) config = bug_reducer_utils.SILToolInvokerConfig(args) nm = bug_reducer_utils.SILNMInvoker(config, tools) input_file = args.input_file extra_args = args.extra_args sil_opt_invoker = bug_reducer_utils.SILOptInvoker(config, tools, input_file, extra_args) # Make sure that the base case /does/ crash. filename = sil_opt_invoker.get_suffixed_filename('base_case') result = sil_opt_invoker.invoke_with_passlist(args.pass_list, filename) # If we succeed, there is no further work to do. if result == 0: print("Success with PassList: %s" % (' '.join(args.pass_list))) return sil_extract_invoker = bug_reducer_utils.SILFuncExtractorInvoker(config, tools, input_file) function_bug_reducer(input_file, nm, sil_opt_invoker, sil_extract_invoker, args.pass_list)
def invoke_pass_bug_reducer(args): """Given a path to a sib file with canonical sil, attempt to find a perturbed list of passes that the perf pipeline""" tools = bug_reducer_utils.SwiftTools(args.swift_build_dir) config = bug_reducer_utils.SILToolInvokerConfig(args) passes = [] if args.pass_list is None: json_data = json.loads(subprocess.check_output( [tools.sil_passpipeline_dumper, '-Performance'])) passes = sum((p[2:] for p in json_data), []) passes = ['-' + x[1] for x in passes] else: passes = ['-' + x for x in args.pass_list] extra_args = [] if args.extra_args is not None: extra_args = args.extra_args sil_opt_invoker = bug_reducer_utils.SILOptInvoker(config, tools, args.input_file, extra_args) pass_bug_reducer(tools, config, passes, sil_opt_invoker, args.reduce_sil)
def random_bug_finder(args): """Given a path to a sib file with canonical sil, attempt to find a perturbed list of passes that the perf pipeline""" tools = bug_reducer_utils.SwiftTools(args.swift_build_dir) config = bug_reducer_utils.SILToolInvokerConfig(args) json_data = json.loads( subprocess.check_output( [tools.sil_passpipeline_dumper, '-Performance'])) passes = sum((p[1:] for p in json_data), []) passes = ['-' + x[1] for x in passes] extra_args = [] if args.extra_args is not None: extra_args.extend(args.extra_args) sil_opt_invoker = bug_reducer_utils.SILOptInvoker(config, tools, args.input_file, extra_args) # Make sure that the base case /does/ crash. max_count = args.max_count for count in range(max_count): print("Running round %i/%i" % (count, max_count)) random.shuffle(passes) filename = sil_opt_invoker.get_suffixed_filename(str(count)) result = sil_opt_invoker.invoke_with_passlist(passes, filename) if result == 0: print("*** Success with PassList: %s" % (' '.join(passes))) continue cmdline = sil_opt_invoker.cmdline_with_passlist(passes) print("*** Fail with PassList: %s" % (' '.join(passes))) print("*** Output File: %s" % filename) print("*** Reproducing commandline: %s" % ' '.join(cmdline)) print("*** Trying to reduce pass list and function list") result = opt_bug_reducer.pass_bug_reducer(tools, config, passes, sil_opt_invoker, True) if not result: sys.exit(-1)