diff --git a/llvm/test/tools/llvm-reduce/Inputs/llvm-as-and-filecheck.py b/llvm/test/tools/llvm-reduce/Inputs/llvm-as-and-filecheck.py new file mode 100644 index 0000000000000..27854c8d22967 --- /dev/null +++ b/llvm/test/tools/llvm-reduce/Inputs/llvm-as-and-filecheck.py @@ -0,0 +1,43 @@ +""" +Script to assemble a text IR file and run FileCheck on the output with the +provided arguments. The first 2 arguments are the paths to the llvm-as and +FileCheck binaries, followed by arguments to be passed to FileCheck. The last +argument is the text IR file to disassemble. + +Usage: + python llvm-as-and-filecheck.py + + [arguments passed to FileCheck] + +""" +import sys +import os +import subprocess + +llvm_as = sys.argv[1] +filecheck = sys.argv[2] +filecheck_args = [ + filecheck +] + +filecheck_args.extend(sys.argv[3:-1]) +ir_file = sys.argv[-1] +bitcode_file = ir_file + ".bc" + +# Verify the IR actually parses since FileCheck is too dumb to know. +assemble = subprocess.Popen([llvm_as, "-o", bitcode_file, ir_file]) +assemble.communicate() + +if assemble.returncode != 0: + print("stderr:") + print(assemble.stderr) + print("stdout:") + print(assemble.stdout) + sys.exit(0) + +filecheck_args.append("--input-file") +filecheck_args.append(ir_file) + +check = subprocess.Popen(filecheck_args) +check.communicate() +sys.exit(check.returncode) diff --git a/llvm/test/tools/llvm-reduce/uselistorder-invalid-ir-output.ll b/llvm/test/tools/llvm-reduce/uselistorder-invalid-ir-output.ll new file mode 100644 index 0000000000000..4bc862bdaed26 --- /dev/null +++ b/llvm/test/tools/llvm-reduce/uselistorder-invalid-ir-output.ll @@ -0,0 +1,51 @@ +; RUN: llvm-reduce -j=1 --abort-on-invalid-reduction \ +; RUN: --delta-passes=operands-zero \ +; RUN: -o %t.reduced.ll %s \ +; RUN: --test=%python --test-arg %p/Inputs/llvm-as-and-filecheck.py \ +; RUN: --test-arg llvm-as \ +; RUN: --test-arg FileCheck --test-arg --check-prefix=INTERESTING \ +; RUN: --test-arg %s + +; Check if the final output really parses +; RUN: not llvm-as -o /dev/null %t.reduced.ll +; RUN: FileCheck --check-prefix=RESULT %s < %t.reduced.ll + + +define void @kernel_ocl_path_trace_direct_lighting(i1 %cond.i, i1 %cmp5.i.i, i32 %arg) { +; INTERESTING: entry: +; INTERESTING: 0 +; INTERESTING: 0 +; INTERESTING: %cmp5.i.i2 = icmp slt i32 {{[0-9]+}}, 0 +entry: + %add_zero_a = add i32 %arg, 0 + %load1.i1 = load i32, ptr addrspace(1) null, align 4 + %add_zero_b = add i32 %arg, 0 + %cmp5.i.i2 = icmp slt i32 1, 0 + br i1 %cond.i, label %if.end13.i.i, label %if.then6.i.i + +; INTERESTING: if.then6.i.i: +; INTERESTING: %cond.i4 = icmp eq i32 %load0.i, 0 +if.then6.i.i: + %load0.i = load i32, ptr addrspace(4) null, align 4 + %cond.i4 = icmp eq i32 %load0.i, 0 + %extractVec358.i.i = insertelement <4 x float> zeroinitializer, float 1.000000e+00, i64 0 + br i1 %cmp5.i.i, label %if.end13.i.i, label %kernel_direct_lighting.exit + +if.end13.i.i: + br i1 false, label %if.then263.i.i, label %if.end273.i.i + +; INTERESTING: if.then263.i.i: +; INTERESTING-NEXT: i32 0 +if.then263.i.i: + %extractVec72.i.i.i11 = shufflevector <3 x float> zeroinitializer, <3 x float> zeroinitializer, <4 x i32> + br i1 %cond.i, label %if.end273.i.i, label %kernel_direct_lighting.exit + +; INTERESTING: if.end273.i.i: +if.end273.i.i: + br label %kernel_direct_lighting.exit + +kernel_direct_lighting.exit: + ret void +} + +; RESULT: uselistorder i32 0, { 4, 0, 5, 1, 6, 2, 7, 3 }