Exemple #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 = swift_tools.SwiftTools(args.swift_build_dir)
    config = swift_tools.SILToolInvokerConfig(args)
    nm = swift_tools.SILNMInvoker(config, tools)

    input_file = args.input_file
    extra_args = args.extra_args
    sil_opt_invoker = swift_tools.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['exit_code'] == 0:
        print("Success with PassList: %s" % (' '.join(args.pass_list)))
        return

    sil_extract_invoker = swift_tools.SILFuncExtractorInvoker(
        config, tools, input_file)

    function_bug_reducer(input_file, nm, sil_opt_invoker, sil_extract_invoker,
                         args.pass_list)
Exemple #2
0
def pass_bug_reducer(tools, config, passes, sil_opt_invoker, reduce_sil):
    # 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['exit_code'] == 0:
        print("Success with base case: %s" % (' '.join(passes)))
        return True
    print("Base case crashes! First trying to reduce the pass list!")

    # Otherwise, reduce the list of passes that cause the optimizer 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)))
    if not reduce_sil:
        return False

    print("*** User requested that we try to reduce SIL. Lets try.")
    input_file = sil_opt_invoker.input_file
    nm = swift_tools.SILNMInvoker(config, tools)
    sil_extract_invoker = swift_tools.SILFuncExtractorInvoker(
        config, tools, input_file)

    func_bug_reducer.function_bug_reducer(input_file, nm, sil_opt_invoker,
                                          sil_extract_invoker, r.target_list)
    print("*** Final Passes: %s" % (' '.join(r.target_list)))
    return False