-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgetbclist.py
30 lines (29 loc) · 1.03 KB
/
getbclist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
import os.path
import os
cur_dir=os.getcwd()
def renameBB(argv):
llvm_dir = argv[1]
for dirpath, dirnames, filenames in os.walk(cur_dir):
for filename in filenames:
if os.path.splitext(filename)[1] == ".llbc":
newfile = os.path.splitext(filename)[0] +".bc"
current = os.path.join(dirpath, filename)
module = os.path.join(dirpath, newfile)
cmd = llvm_dir + "/build/bin/opt -load " + llvm_dir + "/build/lib/bbTaglib.so -bbtag "+ current+" >>"+ module
os.system(cmd)
def getBC():
file_abs = cur_dir + "/bitcode.list"
infile = open(file_abs, "w")
for dirpath, dirnames, filenames in os.walk(cur_dir):
for filename in filenames:
if os.path.splitext(filename)[1] == ".bc":
module = os.path.join(dirpath, filename)
if "timeconst.bc" in module:
continue
infile.write(module)
infile.write("\n")
infile.close()
if __name__ == "__main__":
renameBB(sys.argv)
getBC()