[AArch64] Fix SDNode type mismatches between *.td files and ISel (#116523)
[llvm-project.git] / llvm / utils / merge-stats.py
blobe4de4d395292e0d0c55b5e1a014b3efc27797c76
1 #!/usr/bin/env python3
2 """
3 Merge .stats files generated by llvm tools
5 merge-stats.py takes as argument a list of stats files to merge
6 and output the result on stdout
8 Usage:
9 merge-stats.py $(find ./builddir/ -name "*.stats") > total.stats
10 """
12 import json
13 import sys
15 result = {}
17 for arg in range(1, len(sys.argv)):
18 with open(sys.argv[arg], "r", encoding="utf-8", errors="ignore") as f:
19 text = f.read()
20 try:
21 data = json.loads(text)
22 except:
23 print("ignored %s: failed to parse" % sys.argv[arg], file=sys.stderr)
24 continue
25 for key in data:
26 if key in result:
27 result[key] += data[key]
28 else:
29 result[key] = data[key]
31 out = json.dumps(result, indent=2)
32 print(out)