36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""对比两构建的关键语义行(过滤类型声明顺序噪音)"""
|
|
import sys
|
|
|
|
BK = r'd:\Users\TermiNexus\Desktop\TransPyC\_bk6'
|
|
NOW = r'd:\Users\TermiNexus\Desktop\TransPyC\TransPyV\output'
|
|
FILES = ['43da8de1129ccd08.ll', '57cd9f82dd50783e.ll', 'c356e88e66096eea.ll',
|
|
'e1ea7eaf63a9c3d1.ll', '873bf8790da565fa.ll', '50202407280af718.ll']
|
|
|
|
|
|
def sig(path):
|
|
out = []
|
|
for line in open(path, encoding='utf-8', errors='replace'):
|
|
s = line.strip()
|
|
if s.startswith('%"') and '= type' in s:
|
|
continue # 类型声明顺序噪音
|
|
if ('this_adjust' in s or 'getelementptr' in s
|
|
or 'call i' in s or 'define ' in s or 'declare ' in s):
|
|
out.append(s)
|
|
return sorted(set(out))
|
|
|
|
|
|
for f in FILES:
|
|
a = sig(BK + '\\' + f)
|
|
b = sig(NOW + '\\' + f)
|
|
if a == b:
|
|
print(f'=== {f}: 语义关键行一致 ===')
|
|
continue
|
|
only_a = set(a) - set(b)
|
|
only_b = set(b) - set(a)
|
|
print(f'=== {f}: A-only {len(only_a)}, B-only {len(only_b)} ===')
|
|
for x in list(only_a)[:8]:
|
|
print(' A:', x[:150])
|
|
for x in list(only_b)[:8]:
|
|
print(' B:', x[:150])
|