3 # A small script for comparing IR for unit tests from before and after
4 # a change to the JIT. Assumes old tracelogs are in *.log.old and new
10 # > ./test/run -l -m jit ./test/quick
11 # > find test/ -name '*.log' -exec mv {} {}.old \;
12 # Or, if you ran old tests in a different checkout:
13 # > (cd fbcode-other/hphp && for log in $(find test/ -name '*.log'); do mv $log fbcode-new/hphp/$log.old; done)
15 # Checkout and build your new hhvm, then:
16 # ./test/run -l -m jit ./test/quick
17 # ./test/tools/compare-ir.sh
19 # Produces an ir-diffs.diff file that you can inspect for meaningful
20 # differences in JIT output.
22 TEST_DIRS
=$
(dirname "$0")/..
24 if [[ ! -x $
(command -v parallel
) ]]; then
25 echo "This script requires gnu parallel. Install it and try again."
30 # Strip out hex symbols and other extraneous differences
32 find "$TEST_DIRS" -name '*.log*' | parallel
--gnu -m -n 10 sed -i \
33 -e "'s/TCA: 0x[0-9a-f]*/TCA: 0xdeadbeef/g'" \
34 -e "'s/TCA: 0x[0-9a-f]*(0x[0-9a-f]*)/TCA: 0xdeadbeef(0xdeadbeef)/g'" \
35 -e "'s/PtrToGen(0x[0-9a-f]*)/PtrToGen(0xdeadbeef)/g'" \
36 -e "'s/Array(0x[0-9a-f]*)/Array(0xdeadbeef)/g'" \
37 -e "'s/NamedEntity(0x[0-9a-f]*)/NamedEntity(0xdeadbeef)/g'" \
38 -e "'s/VerifyParamCls.*/VerifyParamCls/g'" \
39 -e "'s/VerifyRetCls.*/VerifyRetCls/g'" \
40 -e "'s/main delta after relocation:.*/main delta after relocation/g'" \
41 -e "'s/cold delta after relocation:.*/cold delta after relocation/g'" \
42 -e "'s/code-gen.cpp [0-9]* /code-gen.cpp 0000 /g'" \
43 -e "'s/0x[0-9a-f]*/0xdeadbeef/g'" \
44 -e "'s/Arr<[0-9]>/Arr/g'" \
45 -e "'s/([0-9]\\+)/(nn)/'" \
46 -e "'s/PtrTo\\|LvalTo/TVPTo/g'" \
47 -e "'s/ \\(TV\\|Lval\\): / TVP: /g'" \
48 -e "'s/ t[0-9]\\+:/ tXX:/g'"
51 # Diff against the old results
53 find "$TEST_DIRS" -name \
*.log | parallel
--gnu diff -wbBdu {}.old
{} > ir-diffs.
diff