I think we need to keep the insertion order of the obsolete constants, because the global variable initializer is created in hierachical way which is bottom up. Therefore, we need to delete the obsolete ones in topdown way. For example:<br>

<br>@rom = global [16 x [1024 x i32]] [[1, 2, 3, ...,1024 ] [2, 4, ...2048] ... ]<br><br>For the above global variable, we also generate 16 constants [1024 x i32] before we generate the initializer every time, so when we delete the obsolete initializer, we need to  make sure we delete the 16 [1024xi32] after [16 x [1024 x i32]] is deleted, otherwise there will be non-use-empty issue.<br>

<br><br>-Sheng<br><br><div class="gmail_quote">On Thu, Nov 29, 2012 at 11:14 PM, Jakub Staszak <span dir="ltr"><<a href="mailto:kubastaszak@gmail.com" target="_blank">kubastaszak@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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">

<div><div class="h5">
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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div class="h5">
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><font color="#888888"><br><br><br><br>-Sheng<br></font></span></span>
<br></div></div>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">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>
</blockquote></div><br>