<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 2, 2014, at 7:22 PM, wuhui1973 <<a href="mailto:wuhui1973@163.com" class="">wuhui1973@163.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div style="line-height: 1.7; font-family: Arial; font-size: 14px;" class=""><div class=""><br class="">Hello Andrew, Hal:</div><div class=""> </div><div class="">I have updated my solution. In these days, I have tried BumpPtrAlloc, but the biggest problem of it is BumpPtrAlloc won't invoke dtor before releasing the memory.</div></div></div></div></blockquote><div><br class=""></div><div>What does the dtor do beside release memory?</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div style="line-height: 1.7; font-family: Arial; font-size: 14px;" class=""><div class=""> And I also consider std::shared_ptr, but not use it for following findings:</div><div class=""> </div><div class="">1> Nodes of TreePatternNode & TreePattern form cycles in reference, I have designed a simple method to recycle them, which can't be used with shared_ptr.</div><div class="">2> After adding the grammar sugar operator-> & operator T(), now most source files using TreePatternHolder & TreePatternNodeHolder now needn't be changed. We can do that because we check reference count on every reference counted objects in every related methods. So any abuse can be found earily as possible.</div></div></div></div></blockquote><div><br class=""></div>Thanks.</div><div><br class=""><blockquote type="cite" class=""><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div style="line-height: 1.7; font-family: Arial; font-size: 14px;" class=""><div class=""> <span style="line-height: 1.7;" class="">In attachment, there are two kinds of suffix:</span></div><div class=""> </div><div class="">*.review is for review</div><div class="">*.fix is for submit</div></div></div></blockquote><div><br class=""></div><div>You can run clang-format before your patch, submit that as a separate patch (no need for a separate review), then submit your patch on top of it.</div><div><br class=""></div><div>-Andy</div><br class=""><blockquote type="cite" class=""><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div style="line-height: 1.7; font-family: Arial; font-size: 14px;" class=""><div class=""><span style="line-height: 1.7;" class=""> </span></div></div></div></blockquote><blockquote type="cite" class=""><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div style="line-height: 1.7; font-family: Arial; font-size: 14px;" class=""><div class="">The reason why need these files is because I had run clang-format on the related source files which results in too many unrelated differences<br class=""><br class=""><br class=""></div><div class=""></div><div id="divNeteaseMailCard" class=""></div><div class=""><br class=""></div>At 2014-08-07 11:59:44, "Andrew Trick" <<a href="mailto:atrick@apple.com" class="">atrick@apple.com</a>> wrote:<br class=""><blockquote id="isReplyContent" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Aug 7, 2014, at 2:29 AM, wuhui1973 <<a href="mailto:wuhui1973@163.com" class="">wuhui1973@163.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: 23px; font-family: Arial; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; white-space: normal; -webkit-text-stroke-width: 0px; display: inline !important;" class="">>> [hui] I am new to tablgen, I hope I can explain it clearly. At some stage in building llvm, tablgen will compile .td file into .inc file (C++ source), it will compile .td file one after one till the stage is done. As now the tree nodes are just allocated but not freed, they get lost </span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: 1.7; font-family: Arial; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; -webkit-text-stroke-width: 0px;" class="">between handling .td files</span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: 1.7; font-family: Arial; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; -webkit-text-stroke-width: 0px;" class="">. So the patch aims to reclaim the memory when finishing one .td file. I think pool allocator can be an option, but as I know, pool allocator is just another sub-project under llvm, has it been built into llvm? And it needs be done by the DSA (data structure analysis) alogrithm?! Is there any example in llvm?</span></div></blockquote></div><br class=""><div class="">Sorry, I wasn’t clear what I was talking about. In LLVM, we have a class called BumpPtrAllocator. You can use that to allocate a set of nodes, then free them all between passes. If that accomplishes our goals for TableGen, then I think it’s the ideal solution.</div><div class=""><br class=""></div><div class="">-Andy</div></blockquote></div></div><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span title="neteasefooter" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span id="netease_mail_footer" class=""></span></span><span id="cid:DEDEE5A5-36D2-4B0E-8932-FF9832726F66@apple.com"><DAGISelMatcherGen.cpp.review></span><span id="cid:961B4E7C-FA5D-4FC9-8259-E3C38297D13E@apple.com"><TableGen.cpp.fix></span><span id="cid:2310FEB1-E05F-4CB6-AB06-A9CA5327F73A@apple.com"><DAGISelMatcherGen.cpp.fix></span><span id="cid:F1573A10-6C21-497C-A7C0-A5F0EF2FAF04@apple.com"><CodeGenDAGPatterns.cpp.fix></span><span id="cid:5B16FE79-55C4-4155-8C15-00AB604EE926@apple.com"><CodeGenDAGPatterns.h.fix></span><span id="cid:47E24A13-566D-4191-AD2B-817A712D5939@apple.com"><CodeGenDAGPatterns.h.review></span><span id="cid:F37C9F08-ED95-4653-89B2-58B39C54CD09@apple.com"><CodeGenDAGPatterns.cpp.review></span></blockquote></div><br class=""></body></html>