<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hello Hal, <span style="font-family: arial; white-space: pre-wrap; line-height: 23.32400131225586px;">Andy, Nadav, Tom</span><span style="line-height: 1.7;"> & all:</span></div><div><br></div><div>I have worked out a solution for the memory leak problem in tblgen. This memory leak problem is known and deliberatly left by the author for later fix.</div><div><br></div><div>My solution follows the author's suggestion - using reference counter to track the TreePatternNode & TreePattern objects.</div><div><br></div><div>Besides, though <span style="line-height: 1.7;">TreePatternNodes</span><span style="line-height: 1.7;"> form DAGs, but with TreePattern, they can form cyclic graph, the solution also includes</span></div><div><span style="line-height: 1.7;"><br></span></div><div><span style="line-height: 1.7;">a method to break the cyclic reference. </span><span style="line-height: 1.7;">The solution detail please refer to the attachment.</span></div><div><span style="line-height: 1.7;"><br></span></div><div>I have checked the solution with following actions:</div><div><br></div><div>1> Check tblgen running log, it looks like this:</div><div><br></div><div>     llvm[3]: Building X86.td register info implementation with tblgen</div><div>     llvm[3]: Building X86.td instruction information with tblgen</div><div>    1. NumTPNAlloc: 84347, NumTPNRel: 20190            <--- TPN: TreePatternNode</div><div>    1. NumTPAlloc: 13441, NumTPRel: 9215                  <---<span style="line-height: 1.7;"> TP: TreePattern</span></div><div>    2. NumTPNAlloc: 84347, NumTPNRel: 83879</div><div>    2. NumTPAlloc: 13441, NumTPRel: 13271</div><div>    468 TPNs remain, 170 TPs remain                            <--- These are cyclic referred nodes</div><div>    Release done</div><div>    3. NumTPNAlloc: 84347, NumTPNRel: 84347</div><div>    3. NumTPAlloc: 13441, NumTPRel: 13441</div><div><br></div><div>    Has confirmed all allocated objects get released during the loadbuild for all supported targets.</div><div><br></div><div>2> Compare the generated .inc file with those generated by sainty code. Has confirmed they all the same.</div><div><br></div><div>3> run "make check" to verify the generated llvm-programs, gets following result:</div><div><b><u>It contains one error, but the sainty code also gives the same result! I will raise the bug report later.</u></b></div><div>FAIL: LLVM :: ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s (6206 of 11281)</div><div>******************** TEST 'LLVM :: ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s' FAILED ********************</div><div>Script:</div><div>--</div><div>/sources/new/build_llvm/Debug+Asserts/bin/llvm-mc -triple=arm64-apple-ios7.0.0 -code-model=small -relocation-model=pic -filetype=obj -o /sources/new/build_llvm/test/ExecutionEngine/RuntimeDyld/AArch64/Output/foo.o /sources/new/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s</div><div>sed "s,<filename>,/sources/new/build_llvm/test/ExecutionEngine/RuntimeDyld/AArch64/Output/foo.o,g" /sources/new/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s > /sources/new/build_llvm/test/ExecutionEngine/RuntimeDyld/AArch64/Output/foo.s</div><div>/sources/new/build_llvm/Debug+Asserts/bin/llvm-rtdyld -triple=arm64-apple-ios7.0.0 -verify -check=/sources/new/build_llvm/test/ExecutionEngine/RuntimeDyld/AArch64/Output/foo.s /sources/new/build_llvm/test/ExecutionEngine/RuntimeDyld/AArch64/Output/foo.o</div><div>--</div><div>Exit Code: 1</div><div><br></div><div>Command Output (stderr):</div><div>--</div><div>Expression 'decode_operand(adrp2, 1) = (stub_addr(/sources/new/build_llvm/test/ExecutionEngine/RuntimeDyld/AArch64/Output/foo.o, __text, _ptr)[32:12] - adrp2[32:12])' is false: 0xfff00000 != 0x0</div><div>/sources/new/build_llvm/Debug+Asserts/bin/llvm-rtdyld: error: some checks in '/sources/new/build_llvm/test/ExecutionEngine/RuntimeDyld/AArch64/Output/foo.s' failed</div><div><span style="line-height: 1.7;">--</span></div><div>********************</div><div>Testing Time: 3155.15s</div><div>********************</div><div>Failing Tests (1):</div><div>    LLVM :: ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s</div><div><br></div><div>  Expected Passes    : 11144</div><div>  Expected Failures  : 101</div><div>  Unsupported Tests  : 35</div><div>  Unexpected Failures: 1</div><div><br></div><div>So I think my solution is correct. Could you review it? Or help to forward to someone concerned? <span style="line-height: 1.7;">Thanks!</span></div><div><br></div><div>Regards</div><div>Hui Wu</div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>