Example #1
0
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)
Example #2
0
def 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)

    passes = []
    early_module_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 if p[0] != 'EarlyModulePasses'), [])
        passes = ['-' + x[1] for x in passes]
        # We assume we have an early module passes that runs until fix point and
        # that is strictly not what is causing the issue.
        #
        # Everything else runs one iteration.
        early_module_passes = [p[2:] for p in json_data
                               if p[0] == 'EarlyModulePasses'][0]
        early_module_passes = ['-' + x[1] for x in early_module_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(args, tools,
                                                      early_module_passes,
                                                      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(passes, filename)
    # If we succeed, there is no further work to do.
    if result == 0:
        print("Success with PassList: %s" % (' '.join(passes)))
        return

    # Otherwise, reduce the list of pases that cause the optimzier to crash.
    r = ReduceMiscompilingPasses(passes, sil_opt_invoker)
    if not r.reduce_list():
        print("Failed to find miscompiling pass list!")
    cmdline = sil_opt_invoker.cmdline_with_passlist(r.target_list)
    print("*** Found miscompiling passes!")
    print("*** Final File: %s" % sil_opt_invoker.input_file)
    print("*** Final Passes: %s" % (' '.join(r.target_list)))
    print("*** Repro command line: %s" % (' '.join(cmdline)))
Example #3
0
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)
Example #4
0
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)

    json_data = json.loads(
        subprocess.check_output(
            [tools.sil_passpipeline_dumper, '-Performance']))
    passes = sum((p[2:] for p in json_data if p[0] != 'EarlyModulePasses'), [])
    passes = ['-' + x[1] for x in passes]

    # We assume we have an early module passes that runs until fix point and
    # that is strictly not what is causing the issue.
    #
    # Everything else runs one iteration.
    early_module_passes = [
        p[2:] for p in json_data if p[0] == 'EarlyModulePasses'
    ][0]
    early_module_passes = ['-' + x[1] for x in early_module_passes]

    sil_opt_invoker = bug_reducer_utils.SILOptInvoker(args, tools,
                                                      early_module_passes)

    # 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(filename, passes)
        if result == 0:
            print("Success with PassList: %s" % (' '.join(passes)))
        else:
            print("Fail with PassList: %s" % (' '.join(passes)))
            print("Output File: %s" % filename)
            sys.exit(-1)