[ThinLTO] Add code comment. NFC
[llvm-complete.git] / utils / DSAclean.py
blob789a825a06712221ef5140798022d5bee7a1bd5b
1 #! /usr/bin/python
3 #changelog:
4 #10/13/2005b: replaced the # in tmp(.#*)* with alphanumeric and _, this will then remove
5 #nodes such as %tmp.1.i and %tmp._i.3
6 #10/13/2005: exntended to remove variables of the form %tmp(.#)* rather than just
7 #%tmp.#, i.e. it now will remove %tmp.12.3.15 etc, additionally fixed a spelling error in
8 #the comments
9 #10/12/2005: now it only removes nodes and edges for which the label is %tmp.# rather
10 #than removing all lines for which the lable CONTAINS %tmp.#
12 from __future__ import print_function
14 import re
15 import sys
16 if( len(sys.argv) < 3 ):
17 print('usage is: ./DSAclean <dot_file_to_be_cleaned> <out_put_file>')
18 sys.exit(1)
19 #get a file object
20 input = open(sys.argv[1], 'r')
21 output = open(sys.argv[2], 'w')
22 #we'll get this one line at a time...while we could just put the whole thing in a string
23 #it would kill old computers
24 buffer = input.readline()
25 while buffer != '':
26 if re.compile("label(\s*)=(\s*)\"\s%tmp(.\w*)*(\s*)\"").search(buffer):
27 #skip next line, write neither this line nor the next
28 buffer = input.readline()
29 else:
30 #this isn't a tmp Node, we can write it
31 output.write(buffer)
32 #prepare for the next iteration
33 buffer = input.readline()
34 input.close()
35 output.close()