blob: d2f5081e7b8cc797d31539e52b0b13fca43ed1f9 [file] [log] [blame]
Kostya Serebryany4d53b742018-05-24 01:43:48 +00001#!/usr/bin/env python
2#===- lib/fuzzer/scripts/merge_data_flow.py ------------------------------===#
3#
4# The LLVM Compiler Infrastructure
5#
6# This file is distributed under the University of Illinois Open Source
7# License. See LICENSE.TXT for details.
8#
9#===------------------------------------------------------------------------===#
10# Merge several data flow traces into one.
11# Usage:
12# merge_data_flow.py trace1 trace2 ... > result
13#===------------------------------------------------------------------------===#
14import sys
15import fileinput
16from array import array
17
18def Merge(a, b):
19 res = array('b')
20 for i in range(0, len(a)):
21 res.append(ord('1' if a[i] == '1' or b[i] == '1' else '0'))
22 return res.tostring()
23
24def main(argv):
25 D = {}
26 for line in fileinput.input():
27 [F,BV] = line.strip().split(' ')
28 if F in D:
29 D[F] = Merge(D[F], BV)
30 else:
31 D[F] = BV;
32 for F in D.keys():
Vitaly Buka4d6b33c2018-06-17 09:11:56 +000033 print("%s %s" % (F, D[F]))
Kostya Serebryany4d53b742018-05-24 01:43:48 +000034
35if __name__ == '__main__':
36 main(sys.argv)