Any particular  reason you use SetVector? It looks like insertion order doesn't make any difference, so SmallPtrSet should be cheaper.<div><br></div><div>- Kuba</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Nov 29, 2012 at 7:45 AM, Sheng Zhou <span dir="ltr"><<a href="mailto:zhousheng00@gmail.com" target="_blank">zhousheng00@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br><br>The attached patch is to improve the memory footprint of pass GlobalOpt. <span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:start;font-style:normal;display:inline!important;font-weight:normal;float:none;line-height:normal;color:rgb(34,34,34);text-transform:none;font-size:13px;white-space:normal;font-family:arial,sans-serif;word-spacing:0px">Please kindly let me know if the patch is good to commit.<br>


I also attached a case to repeat the issue, on which 'opt -globalopt' consumes 3.2GB memory and is stuck for long time. <br>With my patch the memory footprint is reduced to 300MB and GlobalOpt transform finishes in 3mins. (My machine info: 16 Intel(R) Xeon(R) CPU  E5620@2.40GHz, 16GB)<br>


<br>The big memory footprint cause is that current GlobalOpt one by one hoists and stores the leaf element constant into the global array, <br>in each iteration, it recreates the global array initializer constant and leave the old initializer alone. This may result in many obsolete constants left.<br>


For example:  we have global array @rom = global [16 x i32] zeroinitializer<br>After the first element value is hoisted and installed:   @rom = global [16 x i32] [ 1, 0, 0, ... ]<br>After the second element value is installed:  @rom = global [16 x 32] [ 1, 2, 0, 0, ... ]        // here the previous initializer is obsolete<br>


...<br>When the transform is done, we have 15 obsolete initializers left useless.<span class="HOEnZb"><font color="#888888"><br><br><br><br>-Sheng<br></font></span></span>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>