2 Script to disassembles a bitcode file and run FileCheck on the output with the
3 provided arguments. The first 2 arguments are the paths to the llvm-dis and
4 FileCheck binaries, followed by arguments to be passed to FileCheck. The last
5 argument is the bitcode file to disassemble.
8 python llvm-dis-and-filecheck.py
9 <path to llvm-dis> <path to FileCheck>
10 [arguments passed to FileCheck] <path to bitcode file>
19 llvm_dis
= sys
.argv
[1]
20 filecheck
= sys
.argv
[2]
24 filecheck_args
.extend(sys
.argv
[3:-1])
25 bitcode_file
= sys
.argv
[-1]
26 ir_file
= bitcode_file
+ ".ll"
28 disassemble
= subprocess
.Popen([llvm_dis
, "--preserve-ll-uselistorder", "-o", ir_file
, bitcode_file
])
29 if os
.path
.exists(ir_file
+ ".0"):
30 ir_file
= ir_file
+ ".0"
32 disassemble
.communicate()
34 if disassemble
.returncode
!= 0:
36 print(disassemble
.stderr
)
38 print(disassemble
.stdout
)
42 with
open(ir_file
, "r") as ir
:
43 check
= subprocess
.Popen(filecheck_args
, stdin
=ir
, stdout
=sys
.stdout
)
45 sys
.exit(check
.returncode
)