[Frontend] Remove unused includes (NFC) (#116927)
[llvm-project.git] / llvm / test / tools / llvm-reduce / Inputs / llvm-as-and-filecheck.py
blob27854c8d229673708488233d76c005d8db8289e1
1 """
2 Script to assemble a text IR file and run FileCheck on the output with the
3 provided arguments. The first 2 arguments are the paths to the llvm-as and
4 FileCheck binaries, followed by arguments to be passed to FileCheck. The last
5 argument is the text IR file to disassemble.
7 Usage:
8 python llvm-as-and-filecheck.py
9 <path to llvm-as> <path to FileCheck>
10 [arguments passed to FileCheck] <path to text IR file>
12 """
13 import sys
14 import os
15 import subprocess
17 llvm_as = sys.argv[1]
18 filecheck = sys.argv[2]
19 filecheck_args = [
20 filecheck
23 filecheck_args.extend(sys.argv[3:-1])
24 ir_file = sys.argv[-1]
25 bitcode_file = ir_file + ".bc"
27 # Verify the IR actually parses since FileCheck is too dumb to know.
28 assemble = subprocess.Popen([llvm_as, "-o", bitcode_file, ir_file])
29 assemble.communicate()
31 if assemble.returncode != 0:
32 print("stderr:")
33 print(assemble.stderr)
34 print("stdout:")
35 print(assemble.stdout)
36 sys.exit(0)
38 filecheck_args.append("--input-file")
39 filecheck_args.append(ir_file)
41 check = subprocess.Popen(filecheck_args)
42 check.communicate()
43 sys.exit(check.returncode)